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
146f5ddb
Commit
146f5ddb
authored
Aug 21, 2019
by
Kyle Keating
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Namespace the activity module
parent
fee80c6d
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 @
146f5ddb
...
@@ -9,69 +9,55 @@ const { actionTypes } = require('../util');
...
@@ -9,69 +9,55 @@ const { actionTypes } = require('../util');
function
init
()
{
function
init
()
{
return
{
return
{
activity
:
{
/**
/**
* The number of API requests that have started and not yet completed.
* The number of API requests that have started and not yet completed.
*/
*/
activeApiRequests
:
0
,
activeApiRequests
:
0
,
/**
/**
* The number of annotation fetches that have started and not yet completed.
* The number of annotation fetches that have started and not yet completed.
*/
*/
activeAnnotationFetches
:
0
,
activeAnnotationFetches
:
0
,
},
};
};
}
}
const
update
=
{
const
update
=
{
API_REQUEST_STARTED
(
state
)
{
API_REQUEST_STARTED
(
state
)
{
const
{
activity
}
=
state
;
return
{
return
{
activity
:
{
...
state
,
...
activity
,
activeApiRequests
:
state
.
activeApiRequests
+
1
,
activeApiRequests
:
activity
.
activeApiRequests
+
1
,
},
};
};
},
},
API_REQUEST_FINISHED
(
state
)
{
API_REQUEST_FINISHED
(
state
)
{
const
{
activity
}
=
state
;
if
(
state
.
activeApiRequests
===
0
)
{
if
(
activity
.
activeApiRequests
===
0
)
{
throw
new
Error
(
throw
new
Error
(
'API_REQUEST_FINISHED action when no requests were active'
'API_REQUEST_FINISHED action when no requests were active'
);
);
}
}
return
{
return
{
activity
:
{
...
state
,
...
activity
,
activeApiRequests
:
state
.
activeApiRequests
-
1
,
activeApiRequests
:
activity
.
activeApiRequests
-
1
,
},
};
};
},
},
ANNOTATION_FETCH_STARTED
(
state
)
{
ANNOTATION_FETCH_STARTED
(
state
)
{
const
{
activity
}
=
state
;
return
{
return
{
activity
:
{
...
state
,
...
activity
,
activeAnnotationFetches
:
state
.
activeAnnotationFetches
+
1
,
activeAnnotationFetches
:
activity
.
activeAnnotationFetches
+
1
,
},
};
};
},
},
ANNOTATION_FETCH_FINISHED
(
state
)
{
ANNOTATION_FETCH_FINISHED
(
state
)
{
const
{
activity
}
=
state
;
if
(
state
.
activeAnnotationFetches
===
0
)
{
if
(
activity
.
activeAnnotationFetches
===
0
)
{
throw
new
Error
(
throw
new
Error
(
'ANNOTATION_FETCH_FINISHED action when no annotation fetches were active'
'ANNOTATION_FETCH_FINISHED action when no annotation fetches were active'
);
);
}
}
return
{
return
{
activity
:
{
...
state
,
...
activity
,
activeAnnotationFetches
:
state
.
activeAnnotationFetches
-
1
,
activeAnnotationFetches
:
activity
.
activeAnnotationFetches
-
1
,
},
};
};
},
},
};
};
...
@@ -112,6 +98,7 @@ function isFetchingAnnotations(state) {
...
@@ -112,6 +98,7 @@ function isFetchingAnnotations(state) {
module
.
exports
=
{
module
.
exports
=
{
init
,
init
,
update
,
update
,
namespace
:
'activity'
,
actions
:
{
actions
:
{
apiRequestStarted
,
apiRequestStarted
,
...
...
src/sidebar/store/modules/test/activity-test.js
View file @
146f5ddb
...
@@ -57,7 +57,7 @@ describe('sidebar/store/modules/activity', () => {
...
@@ -57,7 +57,7 @@ describe('sidebar/store/modules/activity', () => {
});
});
it
(
'defaults `activeAnnotationFetches` counter to zero'
,
()
=>
{
it
(
'defaults `activeAnnotationFetches` counter to zero'
,
()
=>
{
assert
.
equal
(
store
.
getState
().
activity
.
activeAnnotationFetches
,
0
);
assert
.
equal
(
store
.
get
Root
State
().
activity
.
activeAnnotationFetches
,
0
);
});
});
describe
(
'annotationFetchFinished'
,
()
=>
{
describe
(
'annotationFetchFinished'
,
()
=>
{
...
@@ -70,7 +70,7 @@ describe('sidebar/store/modules/activity', () => {
...
@@ -70,7 +70,7 @@ describe('sidebar/store/modules/activity', () => {
it
(
'increments `activeAnnotationFetches` counter when a new annotation fetch is started'
,
()
=>
{
it
(
'increments `activeAnnotationFetches` counter when a new annotation fetch is started'
,
()
=>
{
store
.
annotationFetchStarted
();
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', () => {
...
@@ -86,7 +86,7 @@ describe('sidebar/store/modules/activity', () => {
store
.
annotationFetchFinished
();
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