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
9ee2948c
Commit
9ee2948c
authored
Apr 07, 2022
by
Robert Knight
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add types for frames store module
parent
9f360335
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
14 deletions
+22
-14
frames.js
src/sidebar/store/modules/frames.js
+22
-14
No files found.
src/sidebar/store/modules/frames.js
View file @
9ee2948c
...
@@ -5,8 +5,7 @@ import {
...
@@ -5,8 +5,7 @@ import {
}
from
'reselect'
;
}
from
'reselect'
;
import
shallowEqual
from
'shallowequal'
;
import
shallowEqual
from
'shallowequal'
;
import
*
as
util
from
'../util'
;
import
{
createStoreModule
,
makeAction
}
from
'../create-store'
;
import
{
createStoreModule
}
from
'../create-store'
;
/**
/**
* @typedef {import('../../../types/annotator').DocumentMetadata} DocumentMetadata
* @typedef {import('../../../types/annotator').DocumentMetadata} DocumentMetadata
...
@@ -27,15 +26,27 @@ const initialState = [];
...
@@ -27,15 +26,27 @@ const initialState = [];
/** @typedef {typeof initialState} State */
/** @typedef {typeof initialState} State */
const
reducers
=
{
const
reducers
=
{
CONNECT_FRAME
:
function
(
state
,
action
)
{
/**
* @param {State} state
* @param {{ frame: Frame }} action
*/
CONNECT_FRAME
(
state
,
action
)
{
return
[...
state
,
action
.
frame
];
return
[...
state
,
action
.
frame
];
},
},
DESTROY_FRAME
:
function
(
state
,
action
)
{
/**
* @param {State} state
* @param {{ frame: Frame }} action
*/
DESTROY_FRAME
(
state
,
action
)
{
return
state
.
filter
(
f
=>
f
!==
action
.
frame
);
return
state
.
filter
(
f
=>
f
!==
action
.
frame
);
},
},
UPDATE_FRAME_ANNOTATION_FETCH_STATUS
:
function
(
state
,
action
)
{
/**
* @param {State} state
* @param {{ uri: string, isAnnotationFetchComplete: boolean }} action
*/
UPDATE_FRAME_ANNOTATION_FETCH_STATUS
(
state
,
action
)
{
const
frames
=
state
.
map
(
frame
=>
{
const
frames
=
state
.
map
(
frame
=>
{
const
match
=
frame
.
uri
&&
frame
.
uri
===
action
.
uri
;
const
match
=
frame
.
uri
&&
frame
.
uri
===
action
.
uri
;
if
(
match
)
{
if
(
match
)
{
...
@@ -50,15 +61,13 @@ const reducers = {
...
@@ -50,15 +61,13 @@ const reducers = {
},
},
};
};
const
actions
=
util
.
actionTypes
(
reducers
);
/**
/**
* Add a frame to the list of frames currently connected to the sidebar app.
* Add a frame to the list of frames currently connected to the sidebar app.
*
*
* @param {Frame} frame
* @param {Frame} frame
*/
*/
function
connectFrame
(
frame
)
{
function
connectFrame
(
frame
)
{
return
{
type
:
actions
.
CONNECT_FRAME
,
frame
}
;
return
makeAction
(
reducers
,
'CONNECT_FRAME'
,
{
frame
})
;
}
}
/**
/**
...
@@ -67,7 +76,7 @@ function connectFrame(frame) {
...
@@ -67,7 +76,7 @@ function connectFrame(frame) {
* @param {Frame} frame
* @param {Frame} frame
*/
*/
function
destroyFrame
(
frame
)
{
function
destroyFrame
(
frame
)
{
return
{
type
:
actions
.
DESTROY_FRAME
,
frame
}
;
return
makeAction
(
reducers
,
'DESTROY_FRAME'
,
{
frame
})
;
}
}
/**
/**
...
@@ -77,17 +86,16 @@ function destroyFrame(frame) {
...
@@ -77,17 +86,16 @@ function destroyFrame(frame) {
* @param {boolean} isFetchComplete
* @param {boolean} isFetchComplete
*/
*/
function
updateFrameAnnotationFetchStatus
(
uri
,
isFetchComplete
)
{
function
updateFrameAnnotationFetchStatus
(
uri
,
isFetchComplete
)
{
return
{
return
makeAction
(
reducers
,
'UPDATE_FRAME_ANNOTATION_FETCH_STATUS'
,
{
type
:
actions
.
UPDATE_FRAME_ANNOTATION_FETCH_STATUS
,
isAnnotationFetchComplete
:
isFetchComplete
,
uri
,
uri
,
};
isAnnotationFetchComplete
:
isFetchComplete
,
});
}
}
/**
/**
* Return the list of frames currently connected to the sidebar app.
* Return the list of frames currently connected to the sidebar app.
*
*
* @
return {Frame[]}
* @
param {State} state
*/
*/
function
frames
(
state
)
{
function
frames
(
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