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
cdce4af9
Commit
cdce4af9
authored
Jul 28, 2020
by
Lyza Danger Gardner
Committed by
Lyza Gardner
Jul 30, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Only force threads to visible if they are not already visible
parent
9ea6d545
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
29 additions
and
22 deletions
+29
-22
threads-test.js
src/sidebar/services/test/threads-test.js
+18
-20
threads.js
src/sidebar/services/threads.js
+11
-2
No files found.
src/sidebar/services/test/threads-test.js
View file @
cdce4af9
...
...
@@ -7,10 +7,10 @@ const NESTED_THREADS = {
id
:
'1'
,
children
:
[
{
id
:
'1a'
,
children
:
[{
id
:
'1ai'
,
children
:
[]
}]
},
{
id
:
'1b'
,
children
:
[]
},
{
id
:
'1b'
,
children
:
[]
,
visible
:
true
},
{
id
:
'1c'
,
children
:
[{
id
:
'1ci'
,
children
:
[]
}],
children
:
[{
id
:
'1ci'
,
children
:
[]
,
visible
:
false
}],
},
],
},
...
...
@@ -21,7 +21,7 @@ const NESTED_THREADS = {
{
id
:
'2b'
,
children
:
[
{
id
:
'2bi'
,
children
:
[]
},
{
id
:
'2bi'
,
children
:
[]
,
visible
:
true
},
{
id
:
'2bii'
,
children
:
[]
},
],
},
...
...
@@ -46,27 +46,32 @@ describe('threadsService', function () {
});
describe
(
'#forceVisible'
,
()
=>
{
it
(
'should set the thread and its children force-visible in the store'
,
()
=>
{
service
.
forceVisible
(
NESTED_THREADS
);
[
let
nonVisibleThreadIds
;
beforeEach
(()
=>
{
nonVisibleThreadIds
=
[
'top'
,
'1'
,
'2'
,
'3'
,
'1a'
,
'1b'
,
'1c'
,
'2a'
,
'2b'
,
'1ai'
,
'1ci'
,
'2bi'
,
'2bii'
,
].
forEach
(
threadId
=>
assert
.
calledWith
(
fakeStore
.
setForcedVisible
,
threadId
)
];
});
it
(
'should set the thread and its children force-visible in the store'
,
()
=>
{
service
.
forceVisible
(
NESTED_THREADS
);
nonVisibleThreadIds
.
forEach
(
threadId
=>
{
assert
.
calledWith
(
fakeStore
.
setForcedVisible
,
threadId
);
assert
.
callCount
(
fakeStore
.
setForcedVisible
,
nonVisibleThreadIds
.
length
);
});
});
it
(
'should not set the visibility on thread ancestors'
,
()
=>
{
// This starts at the level with `id` of '1'
...
...
@@ -76,14 +81,7 @@ describe('threadsService', function () {
for
(
let
i
=
0
;
i
<
fakeStore
.
setForcedVisible
.
callCount
;
i
++
)
{
calledWithThreadIds
.
push
(
fakeStore
.
setForcedVisible
.
getCall
(
i
).
args
[
0
]);
}
assert
.
deepEqual
(
calledWithThreadIds
,
[
'1ai'
,
'1a'
,
'1b'
,
'1ci'
,
'1c'
,
'1'
,
]);
assert
.
deepEqual
(
calledWithThreadIds
,
[
'1ai'
,
'1a'
,
'1ci'
,
'1c'
,
'1'
]);
});
});
});
src/sidebar/services/threads.js
View file @
cdce4af9
/**
* @typedef {import('../util/build-thread').Thread} Thread
*/
// @ngInject
export
default
function
threadsService
(
store
)
{
/**
* Make this thread and all of its children "visible". This has the effect of
* "unhiding" a thread which is currently hidden by an applied search filter
* (as well as its child threads).
* (as well as its child threads). Only threads that are not currently visible
* will be forced visible.
*
* @param {Thread} thread
*/
function
forceVisible
(
thread
)
{
thread
.
children
.
forEach
(
child
=>
{
forceVisible
(
child
);
});
if
(
!
thread
.
visible
)
{
store
.
setForcedVisible
(
thread
.
id
,
true
);
}
}
return
{
forceVisible
,
...
...
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