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
516864c3
Unverified
Commit
516864c3
authored
Jul 02, 2020
by
Robert Knight
Committed by
GitHub
Jul 02, 2020
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #2296 from hypothesis/typecheck-store-modules
Enable typechecking for sidebar/store/modules
parents
7da63a83
2501a772
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
28 additions
and
10 deletions
+28
-10
annotations.js
src/sidebar/store/modules/annotations.js
+8
-4
groups.js
src/sidebar/store/modules/groups.js
+5
-1
real-time-updates.js
src/sidebar/store/modules/real-time-updates.js
+4
-0
selection.js
src/sidebar/store/modules/selection.js
+1
-1
viewer.js
src/sidebar/store/modules/viewer.js
+1
-1
util.js
src/sidebar/store/util.js
+7
-3
tsconfig.json
src/tsconfig.json
+1
-0
api.js
src/types/api.js
+1
-0
No files found.
src/sidebar/store/modules/annotations.js
View file @
516864c3
...
...
@@ -3,6 +3,10 @@
* sidebar.
*/
/**
* @typedef {import('../../../types/api').Annotation} Annotation
*/
import
{
createSelector
}
from
'reselect'
;
import
*
as
metadata
from
'../../util/annotation-metadata'
;
...
...
@@ -56,7 +60,7 @@ function findByTag(annotations, tag) {
* from the service.
*
* @param {Object} annotation
* @param {
Number
} tag - The `$tag` value that should be used for this
* @param {
string
} tag - The `$tag` value that should be used for this
* if it doesn't have a `$tag` already
* @return {Object} - annotation with local (`$*`) fields set
*/
...
...
@@ -226,7 +230,7 @@ function updateFlagStatus(id, isFlagged) {
/**
* Add these `annotations` to the current collection of annotations in the store.
*
* @param {
Object}[]
annotations - Array of annotation objects to add.
* @param {
Annotation[]}
annotations - Array of annotation objects to add.
*/
function
addAnnotations
(
annotations
)
{
return
function
(
dispatch
,
getState
)
{
...
...
@@ -344,7 +348,7 @@ function unhideAnnotation(id) {
/**
* Return all loaded annotations which have been saved to the server.
*
* @param {
state}
- The global app state
* @param {
Object} state
- The global app state
*/
function
savedAnnotations
(
state
)
{
return
state
.
annotations
.
annotations
.
filter
(
function
(
ann
)
{
...
...
@@ -365,7 +369,7 @@ function annotationExists(state, id) {
* If an annotation does not have an ID because it has not been created on
* the server, there will be no entry for it in the returned array.
*
* @param {string[]} Local tags of annotations to look up
* @param {string[]}
tags -
Local tags of annotations to look up
*/
function
findIDsForTags
(
state
,
tags
)
{
const
ids
=
[];
...
...
src/sidebar/store/modules/groups.js
View file @
516864c3
...
...
@@ -4,6 +4,10 @@ import * as util from '../util';
import
session
from
'./session'
;
/**
* @typedef {import('../../../types/api').Group} Group
*/
function
init
()
{
return
{
/**
...
...
@@ -97,7 +101,7 @@ function loadGroups(groups) {
/**
* Return the currently focused group.
*
* @return {Group|null}
* @return {Group|
undefined|
null}
*/
function
focusedGroup
(
state
)
{
if
(
!
state
.
groups
.
focusedGroupId
)
{
...
...
src/sidebar/store/modules/real-time-updates.js
View file @
516864c3
...
...
@@ -3,6 +3,10 @@
* WebSocket connection to h's real-time API.
*/
/**
* @typedef {import('../../../types/api').Annotation} Annotation
*/
import
{
createSelector
}
from
'reselect'
;
import
{
actionTypes
}
from
'../util'
;
...
...
src/sidebar/store/modules/selection.js
View file @
516864c3
...
...
@@ -313,7 +313,7 @@ function setForceVisible(id, visible) {
/**
* Sets which annotations are currently focused.
*
* @param {
Array<string>}
Tags of annotations to focus
* @param {
string[]} tags -
Tags of annotations to focus
*/
function
focusAnnotations
(
tags
)
{
return
{
...
...
src/sidebar/store/modules/viewer.js
View file @
516864c3
...
...
@@ -41,7 +41,7 @@ function setShowHighlights(show) {
}
/**
* @param {boolean}
sidebarState
- If the sidebar is open
* @param {boolean}
opened
- If the sidebar is open
*/
function
setSidebarOpened
(
opened
)
{
return
{
type
:
actions
.
SET_SIDEBAR_OPENED
,
opened
};
...
...
src/sidebar/store/util.js
View file @
516864c3
/**
* Return an object where each key in `updateFns` is mapped to the key itself.
*
* @template {Object.<string,Function>} T
* @param {T} reducers - Object containing reducer functions
* @return {{ [index in keyof T]: string }}
*/
export
function
actionTypes
(
updateFn
s
)
{
return
Object
.
keys
(
updateFn
s
).
reduce
(
function
(
types
,
key
)
{
export
function
actionTypes
(
reducer
s
)
{
return
Object
.
keys
(
reducer
s
).
reduce
(
function
(
types
,
key
)
{
types
[
key
]
=
key
;
return
types
;
},
{}
);
},
/** @type {any} */
({})
);
}
/**
...
...
src/tsconfig.json
View file @
516864c3
...
...
@@ -18,6 +18,7 @@
"shared/*.js"
,
"shared/components/*.js"
,
"sidebar/*.js"
,
"sidebar/store/modules/*.js"
,
"sidebar/services/*.js"
,
"sidebar/util/*.js"
],
...
...
src/types/api.js
View file @
516864c3
...
...
@@ -12,6 +12,7 @@
* @prop {string} [id]
* @prop {string[]} [references]
* @prop {string} created
* @prop {string} group
* @prop {string} updated
* @prop {string[]} tags
* @prop {string} text
...
...
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