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
a20c37b8
Commit
a20c37b8
authored
Apr 19, 2021
by
Robert Knight
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Convert `threads` service to an ES class
Part of
https://github.com/hypothesis/client/issues/3298
parent
9861eaf1
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
20 additions
and
14 deletions
+20
-14
Thread.js
src/sidebar/components/Thread.js
+1
-1
index.js
src/sidebar/index.js
+2
-2
threads-test.js
src/sidebar/services/test/threads-test.js
+3
-3
threads.js
src/sidebar/services/threads.js
+14
-8
No files found.
src/sidebar/components/Thread.js
View file @
a20c37b8
...
...
@@ -14,7 +14,7 @@ import ModerationBanner from './ModerationBanner';
/**
* @typedef ThreadProps
* @prop {Thread} thread
* @prop {
Object} threadsService - Injected s
ervice
* @prop {
import('../services/threads').ThreadsService} threadsS
ervice
*/
/**
...
...
src/sidebar/index.js
View file @
a20c37b8
...
...
@@ -112,7 +112,7 @@ import sessionService from './services/session';
import
{
StreamFilter
}
from
'./services/stream-filter'
;
import
streamerService
from
'./services/streamer'
;
import
tagsService
from
'./services/tags'
;
import
threadsService
from
'./services/threads'
;
import
{
ThreadsService
}
from
'./services/threads'
;
import
{
ToastMessengerService
}
from
'./services/toast-messenger'
;
// Redux store.
...
...
@@ -150,7 +150,7 @@ function startApp(config, appEl) {
.
register
(
'streamer'
,
streamerService
)
.
register
(
'streamFilter'
,
StreamFilter
)
.
register
(
'tags'
,
tagsService
)
.
register
(
'threadsService'
,
t
hreadsService
)
.
register
(
'threadsService'
,
T
hreadsService
)
.
register
(
'toastMessenger'
,
ToastMessengerService
)
.
register
(
'store'
,
store
);
...
...
src/sidebar/services/test/threads-test.js
View file @
a20c37b8
import
threadsService
from
'../threads'
;
import
{
ThreadsService
}
from
'../threads'
;
const
NESTED_THREADS
=
{
id
:
'top'
,
...
...
@@ -60,7 +60,7 @@ const NESTED_THREADS = {
],
};
describe
(
'
t
hreadsService'
,
()
=>
{
describe
(
'
T
hreadsService'
,
()
=>
{
let
fakeStore
;
let
service
;
...
...
@@ -68,7 +68,7 @@ describe('threadsService', () => {
fakeStore
=
{
setForcedVisible
:
sinon
.
stub
(),
};
service
=
t
hreadsService
(
fakeStore
);
service
=
new
T
hreadsService
(
fakeStore
);
});
describe
(
'#forceVisible'
,
()
=>
{
...
...
src/sidebar/services/threads.js
View file @
a20c37b8
...
...
@@ -2,8 +2,18 @@
* @typedef {import('../helpers/build-thread').Thread} Thread
*/
/**
* A service for performing operations related to the current set of threads.
*/
// @inject
export
default
function
threadsService
(
store
)
{
export
class
ThreadsService
{
/**
* @param {import('../store').SidebarStore} store
*/
constructor
(
store
)
{
this
.
_store
=
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
...
...
@@ -12,16 +22,12 @@ export default function threadsService(store) {
*
* @param {Thread} thread
*/
f
unction
f
orceVisible
(
thread
)
{
forceVisible
(
thread
)
{
thread
.
children
.
forEach
(
child
=>
{
forceVisible
(
child
);
this
.
forceVisible
(
child
);
});
if
(
!
thread
.
visible
)
{
store
.
setForcedVisible
(
thread
.
id
,
true
);
this
.
_
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