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
6cba2e65
Commit
6cba2e65
authored
Mar 31, 2022
by
Robert Knight
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add types for "directLinked" store module
parent
65d131cd
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
33 additions
and
24 deletions
+33
-24
direct-linked.js
src/sidebar/store/modules/direct-linked.js
+33
-24
No files found.
src/sidebar/store/modules/direct-linked.js
View file @
6cba2e65
import
*
as
util
from
'../util'
;
import
{
createStoreModule
,
makeAction
}
from
'../create-store'
;
import
{
createStoreModule
}
from
'../create-store'
;
/** @param {import('../../../types/config').SidebarSettings} settings */
function
initialState
(
settings
)
{
function
initialState
(
settings
)
{
return
{
return
{
/**
/**
...
@@ -42,29 +41,47 @@ function initialState(settings) {
...
@@ -42,29 +41,47 @@ function initialState(settings) {
};
};
}
}
/** @typedef {ReturnType<initialState>} State */
const
reducers
=
{
const
reducers
=
{
/**
* @param {State} state
* @param {{ directLinkedGroupFetchFailed: boolean }} action
*/
UPDATE_DIRECT_LINKED_GROUP_FETCH_FAILED
(
state
,
action
)
{
UPDATE_DIRECT_LINKED_GROUP_FETCH_FAILED
(
state
,
action
)
{
return
{
return
{
directLinkedGroupFetchFailed
:
action
.
directLinkedGroupFetchFailed
,
directLinkedGroupFetchFailed
:
action
.
directLinkedGroupFetchFailed
,
};
};
},
},
/**
* @param {State} state
* @param {{ directLinkedGroupId: string }} action
*/
UPDATE_DIRECT_LINKED_GROUP_ID
(
state
,
action
)
{
UPDATE_DIRECT_LINKED_GROUP_ID
(
state
,
action
)
{
return
{
return
{
directLinkedGroupId
:
action
.
directLinkedGroupId
,
directLinkedGroupId
:
action
.
directLinkedGroupId
,
};
};
},
},
/**
* @param {State} state
* @param {{ directLinkedAnnotationId: string }} action
*/
UPDATE_DIRECT_LINKED_ANNOTATION_ID
(
state
,
action
)
{
UPDATE_DIRECT_LINKED_ANNOTATION_ID
(
state
,
action
)
{
return
{
return
{
directLinkedAnnotationId
:
action
.
directLinkedAnnotationId
,
directLinkedAnnotationId
:
action
.
directLinkedAnnotationId
,
};
};
},
},
CLEAR_DIRECT_LINKED_IDS
()
{
CLEAR_DIRECT_LINKED_IDS
()
{
return
{
return
{
directLinkedAnnotationId
:
null
,
directLinkedAnnotationId
:
null
,
directLinkedGroupId
:
null
,
directLinkedGroupId
:
null
,
};
};
},
},
CLEAR_SELECTION
:
function
()
{
CLEAR_SELECTION
()
{
return
{
return
{
directLinkedAnnotationId
:
null
,
directLinkedAnnotationId
:
null
,
directLinkedGroupId
:
null
,
directLinkedGroupId
:
null
,
...
@@ -73,46 +90,40 @@ const reducers = {
...
@@ -73,46 +90,40 @@ const reducers = {
},
},
};
};
const
actions
=
util
.
actionTypes
(
reducers
);
/**
/**
* Set the direct linked group id.
* Set the direct linked group id.
*/
*/
function
setDirectLinkedGroupId
(
groupId
)
{
function
setDirectLinkedGroupId
(
groupId
)
{
return
{
return
makeAction
(
reducers
,
'UPDATE_DIRECT_LINKED_GROUP_ID'
,
{
type
:
actions
.
UPDATE_DIRECT_LINKED_GROUP_ID
,
directLinkedGroupId
:
groupId
,
directLinkedGroupId
:
groupId
,
};
}
)
;
}
}
/**
/**
* Set the direct linked annotation's id.
* Set the direct linked annotation's id.
*/
*/
function
setDirectLinkedAnnotationId
(
annId
)
{
function
setDirectLinkedAnnotationId
(
annId
)
{
return
{
return
makeAction
(
reducers
,
'UPDATE_DIRECT_LINKED_ANNOTATION_ID'
,
{
type
:
actions
.
UPDATE_DIRECT_LINKED_ANNOTATION_ID
,
directLinkedAnnotationId
:
annId
,
directLinkedAnnotationId
:
annId
,
};
}
)
;
}
}
/**
/**
* Set the direct linked group fetch failure to true.
* Set the direct linked group fetch failure to true.
*/
*/
function
setDirectLinkedGroupFetchFailed
()
{
function
setDirectLinkedGroupFetchFailed
()
{
return
{
return
makeAction
(
reducers
,
'UPDATE_DIRECT_LINKED_GROUP_FETCH_FAILED'
,
{
type
:
actions
.
UPDATE_DIRECT_LINKED_GROUP_FETCH_FAILED
,
directLinkedGroupFetchFailed
:
true
,
directLinkedGroupFetchFailed
:
true
,
};
}
)
;
}
}
/**
/**
* Clear the direct linked group fetch failure.
* Clear the direct linked group fetch failure.
*/
*/
function
clearDirectLinkedGroupFetchFailed
()
{
function
clearDirectLinkedGroupFetchFailed
()
{
return
{
return
makeAction
(
reducers
,
'UPDATE_DIRECT_LINKED_GROUP_FETCH_FAILED'
,
{
type
:
actions
.
UPDATE_DIRECT_LINKED_GROUP_FETCH_FAILED
,
directLinkedGroupFetchFailed
:
false
,
directLinkedGroupFetchFailed
:
false
,
};
}
)
;
}
}
/**
/**
...
@@ -122,22 +133,20 @@ function clearDirectLinkedGroupFetchFailed() {
...
@@ -122,22 +133,20 @@ function clearDirectLinkedGroupFetchFailed() {
* not affect future group/annotation etc. fetches.
* not affect future group/annotation etc. fetches.
*/
*/
function
clearDirectLinkedIds
()
{
function
clearDirectLinkedIds
()
{
return
{
return
makeAction
(
reducers
,
'CLEAR_DIRECT_LINKED_IDS'
,
undefined
);
type
:
actions
.
CLEAR_DIRECT_LINKED_IDS
,
};
}
}
/**
/** @param {State} state */
* Selectors
*/
function
directLinkedAnnotationId
(
state
)
{
function
directLinkedAnnotationId
(
state
)
{
return
state
.
directLinkedAnnotationId
;
return
state
.
directLinkedAnnotationId
;
}
}
/** @param {State} state */
function
directLinkedGroupId
(
state
)
{
function
directLinkedGroupId
(
state
)
{
return
state
.
directLinkedGroupId
;
return
state
.
directLinkedGroupId
;
}
}
/** @param {State} state */
function
directLinkedGroupFetchFailed
(
state
)
{
function
directLinkedGroupFetchFailed
(
state
)
{
return
state
.
directLinkedGroupFetchFailed
;
return
state
.
directLinkedGroupFetchFailed
;
}
}
...
...
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