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
524ae825
Commit
524ae825
authored
Jan 05, 2023
by
Lyza Danger Gardner
Committed by
Lyza Gardner
Jan 09, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Convert Thread component to TS
parent
d11a78eb
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
14 deletions
+17
-14
Thread.tsx
src/sidebar/components/Thread.tsx
+17
-14
No files found.
src/sidebar/components/Thread.
js
→
src/sidebar/components/Thread.
tsx
View file @
524ae825
...
...
@@ -10,24 +10,28 @@ import { useCallback, useMemo } from 'preact/hooks';
import
{
useSidebarStore
}
from
'../store'
;
import
{
withServices
}
from
'../service-context'
;
import
{
countHidden
,
countVisible
}
from
'../helpers/thread'
;
import
type
{
Thread
as
IThread
}
from
'../helpers/build-thread'
;
import
type
{
ThreadsService
}
from
'../services/threads'
;
import
Annotation
from
'./Annotation'
;
import
AnnotationHeader
from
'./Annotation/AnnotationHeader'
;
import
EmptyAnnotation
from
'./Annotation/EmptyAnnotation'
;
import
ModerationBanner
from
'./ModerationBanner'
;
/** @typedef {import('../helpers/build-thread').Thread} Thread */
type
ThreadCollapseControlProps
=
{
threadIsCollapsed
:
boolean
;
onToggleReplies
:
()
=>
void
;
};
/**
* Render a gutter area to the left of a thread's content with a control for
* expanding/collapsing the thread and a visual vertical line showing the
* extent of the thread.
*
* @param {object} props
* @param {boolean} props.threadIsCollapsed
* @param {() => void} props.onToggleReplies
*/
function
ThreadCollapseControl
({
threadIsCollapsed
,
onToggleReplies
})
{
function
ThreadCollapseControl
({
threadIsCollapsed
,
onToggleReplies
,
}:
ThreadCollapseControlProps
)
{
const
ToggleIcon
=
threadIsCollapsed
?
CaretRightIcon
:
MenuExpandIcon
;
const
toggleTitle
=
threadIsCollapsed
?
'Expand replies'
:
'Collapse replies'
;
return
(
...
...
@@ -69,11 +73,12 @@ function ThreadCollapseControl({ threadIsCollapsed, onToggleReplies }) {
);
}
/**
* @typedef ThreadProps
* @prop {Thread} thread
* @prop {import('../services/threads').ThreadsService} threadsService
*/
export
type
ThreadProps
=
{
thread
:
IThread
;
// injected
threadsService
:
ThreadsService
;
};
/**
* A thread, which contains a single annotation at its top level, and its
...
...
@@ -89,10 +94,8 @@ function ThreadCollapseControl({ threadIsCollapsed, onToggleReplies }) {
*
* Top-level threads do not render a collapse control, as they are not
* collapsible.
*
* @param {ThreadProps} props
*/
function
Thread
({
thread
,
threadsService
})
{
function
Thread
({
thread
,
threadsService
}
:
ThreadProps
)
{
const
isReply
=
!!
thread
.
parent
;
// If rendering child threads, only render those that have at least one
...
...
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