Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
coopwire-hypothesis
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
孙灵跃 Leon Sun
coopwire-hypothesis
Commits
1125ec3a
Commit
1125ec3a
authored
Jul 05, 2023
by
Alejandro Celaya
Committed by
Alejandro Celaya
Jul 06, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Migrate defaults store module to TypeScript
parent
dda46a72
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
23 deletions
+13
-23
defaults.ts
src/sidebar/store/modules/defaults.ts
+13
-23
No files found.
src/sidebar/store/modules/defaults.
j
s
→
src/sidebar/store/modules/defaults.
t
s
View file @
1125ec3a
...
@@ -14,31 +14,25 @@ import { createStoreModule, makeAction } from '../create-store';
...
@@ -14,31 +14,25 @@ import { createStoreModule, makeAction } from '../create-store';
* `persistedDefaults` service.
* `persistedDefaults` service.
*/
*/
const
initial
State
=
{
export
type
State
=
{
annotationPrivacy
:
/** @type {'private'|'shared'|null} */
(
null
),
annotationPrivacy
:
'private'
|
'shared'
|
null
;
focusedGroup
:
/** @type {string|null} */
(
null
),
focusedGroup
:
string
|
null
;
};
};
/**
export
type
Key
=
keyof
State
;
* @typedef {keyof initialState} Key
* @typedef {typeof initialState} State
const
initialState
:
State
=
{
*/
annotationPrivacy
:
null
,
focusedGroup
:
null
,
};
const
reducers
=
{
const
reducers
=
{
/**
SET_DEFAULT
(
state
:
State
,
action
:
{
defaultKey
:
Key
;
value
:
string
|
null
})
{
* @param {State} state
* @param {{ defaultKey: Key, value: string|null }} action
*/
SET_DEFAULT
(
state
,
action
)
{
return
{
[
action
.
defaultKey
]:
action
.
value
};
return
{
[
action
.
defaultKey
]:
action
.
value
};
},
},
};
};
/**
function
setDefault
(
defaultKey
:
Key
,
value
:
string
|
null
)
{
* @param {Key} defaultKey
* @param {string|null} value
*/
function
setDefault
(
defaultKey
,
value
)
{
return
makeAction
(
reducers
,
'SET_DEFAULT'
,
{
defaultKey
,
value
});
return
makeAction
(
reducers
,
'SET_DEFAULT'
,
{
defaultKey
,
value
});
}
}
...
@@ -46,16 +40,12 @@ function setDefault(defaultKey, value) {
...
@@ -46,16 +40,12 @@ function setDefault(defaultKey, value) {
/**
/**
* Retrieve the state's current value for `defaultKey`.
* Retrieve the state's current value for `defaultKey`.
*
* @param {State} state
* @param {Key} defaultKey
*/
*/
function
getDefault
(
state
,
default
Key
)
{
function
getDefault
(
state
:
State
,
defaultKey
:
Key
)
{
return
state
[
defaultKey
];
return
state
[
defaultKey
];
}
}
/** @param {State} state */
function
getDefaults
(
state
:
State
)
{
function
getDefaults
(
state
)
{
return
state
;
return
state
;
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment