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
266f85b8
Unverified
Commit
266f85b8
authored
May 08, 2019
by
Hannah Stepanek
Committed by
GitHub
May 08, 2019
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1106 from hypothesis/fix-dup-group
Fix bug where direct linked group is duplicated
parents
e25c5101
a57a0e69
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
25 additions
and
4 deletions
+25
-4
groups.js
src/sidebar/services/groups.js
+3
-1
groups-test.js
src/sidebar/services/test/groups-test.js
+19
-0
groups.js
src/sidebar/util/groups.js
+3
-3
No files found.
src/sidebar/services/groups.js
View file @
266f85b8
...
...
@@ -213,9 +213,11 @@ function groups(
}
return
Promise
.
all
(
groupApiRequests
).
then
(
([
myGroups
,
featuredGroups
,
token
,
selectedGroup
])
=>
[
// Don't add the selectedGroup if it's already in the featuredGroups.
combineGroups
(
myGroups
,
selectedGroup
!==
undefined
selectedGroup
!==
undefined
&&
!
featuredGroups
.
some
(
g
=>
g
.
id
===
selectedGroup
.
id
)
?
featuredGroups
.
concat
([
selectedGroup
])
:
featuredGroups
,
documentUri
...
...
src/sidebar/services/test/groups-test.js
View file @
266f85b8
...
...
@@ -230,6 +230,25 @@ describe('groups', function() {
});
});
// TODO: Add a de-dup test for the direct-linked annotation.
it
(
'does not duplicate groups if the direct-linked group is also a featured group'
,
()
=>
{
const
svc
=
service
();
// Set the direct-linked group to dummyGroups[0].
fakeSettings
.
group
=
dummyGroups
[
0
].
id
;
fakeApi
.
group
.
read
.
returns
(
Promise
.
resolve
(
dummyGroups
[
0
]));
// Include the dummyGroups[0] in the featured groups.
fakeApi
.
profile
.
groups
.
read
.
returns
(
Promise
.
resolve
([]));
fakeApi
.
groups
.
list
.
returns
(
Promise
.
resolve
([
dummyGroups
[
0
]]));
return
svc
.
load
().
then
(
groups
=>
{
const
groupIds
=
groups
.
map
(
g
=>
g
.
id
);
assert
.
deepEqual
(
groupIds
,
[
fakeSettings
.
group
]);
});
});
it
(
'combines groups from all 3 endpoints if there is a selectedGroup'
,
()
=>
{
const
svc
=
service
();
...
...
src/sidebar/util/groups.js
View file @
266f85b8
...
...
@@ -5,11 +5,11 @@ const escapeStringRegexp = require('escape-string-regexp');
/**
* Combine groups from multiple api calls together to form a unique list of groups.
* Add an isMember property to each group indicating whether the logged in user is a member.
* Add an isScopedToUri property to each group indicating whether the
group can be annotated
*
in based on group scoping and the uri of the current pag
e.
* Add an isScopedToUri property to each group indicating whether the
uri matches the group's
*
uri patterns. If no uri patterns are specified, defaults to Tru
e.
*
* @param {Group[]} userGroups - groups the user is a member of
* @param {Group[]} featuredGroups -
groups scoped to the particular uri, authority, and user
* @param {Group[]} featuredGroups -
all other groups, may include some duplicates from the userGroups
* @param {string} uri - uri of the current page
*/
function
combineGroups
(
userGroups
,
featuredGroups
,
uri
)
{
...
...
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