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
4bc0827e
Unverified
Commit
4bc0827e
authored
Aug 22, 2019
by
Robert Knight
Committed by
GitHub
Aug 22, 2019
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1316 from hypothesis/namespace-activity-module
Namespace the activity module
parents
fee80c6d
146f5ddb
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
35 deletions
+22
-35
activity.js
src/sidebar/store/modules/activity.js
+19
-32
activity-test.js
src/sidebar/store/modules/test/activity-test.js
+3
-3
No files found.
src/sidebar/store/modules/activity.js
View file @
4bc0827e
...
...
@@ -9,69 +9,55 @@ const { actionTypes } = require('../util');
function
init
()
{
return
{
activity
:
{
/**
* The number of API requests that have started and not yet completed.
*/
activeApiRequests
:
0
,
/**
* The number of annotation fetches that have started and not yet completed.
*/
activeAnnotationFetches
:
0
,
},
/**
* The number of API requests that have started and not yet completed.
*/
activeApiRequests
:
0
,
/**
* The number of annotation fetches that have started and not yet completed.
*/
activeAnnotationFetches
:
0
,
};
}
const
update
=
{
API_REQUEST_STARTED
(
state
)
{
const
{
activity
}
=
state
;
return
{
activity
:
{
...
activity
,
activeApiRequests
:
activity
.
activeApiRequests
+
1
,
},
...
state
,
activeApiRequests
:
state
.
activeApiRequests
+
1
,
};
},
API_REQUEST_FINISHED
(
state
)
{
const
{
activity
}
=
state
;
if
(
activity
.
activeApiRequests
===
0
)
{
if
(
state
.
activeApiRequests
===
0
)
{
throw
new
Error
(
'API_REQUEST_FINISHED action when no requests were active'
);
}
return
{
activity
:
{
...
activity
,
activeApiRequests
:
activity
.
activeApiRequests
-
1
,
},
...
state
,
activeApiRequests
:
state
.
activeApiRequests
-
1
,
};
},
ANNOTATION_FETCH_STARTED
(
state
)
{
const
{
activity
}
=
state
;
return
{
activity
:
{
...
activity
,
activeAnnotationFetches
:
activity
.
activeAnnotationFetches
+
1
,
},
...
state
,
activeAnnotationFetches
:
state
.
activeAnnotationFetches
+
1
,
};
},
ANNOTATION_FETCH_FINISHED
(
state
)
{
const
{
activity
}
=
state
;
if
(
activity
.
activeAnnotationFetches
===
0
)
{
if
(
state
.
activeAnnotationFetches
===
0
)
{
throw
new
Error
(
'ANNOTATION_FETCH_FINISHED action when no annotation fetches were active'
);
}
return
{
activity
:
{
...
activity
,
activeAnnotationFetches
:
activity
.
activeAnnotationFetches
-
1
,
},
...
state
,
activeAnnotationFetches
:
state
.
activeAnnotationFetches
-
1
,
};
},
};
...
...
@@ -112,6 +98,7 @@ function isFetchingAnnotations(state) {
module
.
exports
=
{
init
,
update
,
namespace
:
'activity'
,
actions
:
{
apiRequestStarted
,
...
...
src/sidebar/store/modules/test/activity-test.js
View file @
4bc0827e
...
...
@@ -57,7 +57,7 @@ describe('sidebar/store/modules/activity', () => {
});
it
(
'defaults `activeAnnotationFetches` counter to zero'
,
()
=>
{
assert
.
equal
(
store
.
getState
().
activity
.
activeAnnotationFetches
,
0
);
assert
.
equal
(
store
.
get
Root
State
().
activity
.
activeAnnotationFetches
,
0
);
});
describe
(
'annotationFetchFinished'
,
()
=>
{
...
...
@@ -70,7 +70,7 @@ describe('sidebar/store/modules/activity', () => {
it
(
'increments `activeAnnotationFetches` counter when a new annotation fetch is started'
,
()
=>
{
store
.
annotationFetchStarted
();
assert
.
equal
(
store
.
getState
().
activity
.
activeAnnotationFetches
,
1
);
assert
.
equal
(
store
.
get
Root
State
().
activity
.
activeAnnotationFetches
,
1
);
});
});
...
...
@@ -86,7 +86,7 @@ describe('sidebar/store/modules/activity', () => {
store
.
annotationFetchFinished
();
assert
.
equal
(
store
.
getState
().
activity
.
activeAnnotationFetches
,
0
);
assert
.
equal
(
store
.
get
Root
State
().
activity
.
activeAnnotationFetches
,
0
);
});
});
...
...
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