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
6ad2f0d0
Commit
6ad2f0d0
authored
Jan 18, 2023
by
Lyza Danger Gardner
Committed by
Lyza Gardner
Jan 19, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Convert `NotebookView` to TS
parent
9133aeb5
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
12 deletions
+11
-12
NotebookView.tsx
src/sidebar/components/NotebookView.tsx
+11
-12
No files found.
src/sidebar/components/NotebookView.
js
→
src/sidebar/components/NotebookView.
tsx
View file @
6ad2f0d0
...
...
@@ -4,6 +4,8 @@ import scrollIntoView from 'scroll-into-view';
import
{
ResultSizeError
}
from
'../search-client'
;
import
{
withServices
}
from
'../service-context'
;
import
type
{
LoadAnnotationsService
}
from
'../services/load-annotations'
;
import
type
{
StreamerService
}
from
'../services/streamer'
;
import
{
useSidebarStore
}
from
'../store'
;
import
NotebookFilters
from
'./NotebookFilters'
;
...
...
@@ -11,18 +13,17 @@ import NotebookResultCount from './NotebookResultCount';
import
PaginatedThreadList
from
'./PaginatedThreadList'
;
import
{
useRootThread
}
from
'./hooks/use-root-thread'
;
/**
* @typedef NotebookViewProps
* @prop {import('../services/load-annotations').LoadAnnotationsService} loadAnnotationsService
* @prop {import('../services/streamer').StreamerService} streamer
*/
export
type
NotebookViewProps
=
{
// injected
loadAnnotationsService
:
LoadAnnotationsService
;
streamer
:
StreamerService
;
};
/**
* The main content of the "notebook" route (https://hypothes.is/notebook)
*
* @param {NotebookViewProps} props
*/
function
NotebookView
({
loadAnnotationsService
,
streamer
})
{
function
NotebookView
({
loadAnnotationsService
,
streamer
}
:
NotebookViewProps
)
{
const
store
=
useSidebarStore
();
const
filters
=
store
.
getFilterValues
();
...
...
@@ -56,8 +57,7 @@ function NotebookView({ loadAnnotationsService, streamer }) {
// of them: this is a performance safety valve.
const
maxResults
=
5000
;
/** @param {Error} error */
const
onLoadError
=
error
=>
{
const
onLoadError
=
(
error
:
Error
)
=>
{
if
(
error
instanceof
ResultSizeError
)
{
setHasTooManyAnnotationsError
(
true
);
}
...
...
@@ -102,8 +102,7 @@ function NotebookView({ loadAnnotationsService, streamer }) {
}
},
[
loadAnnotationsService
,
groupId
,
store
]);
/** @param {number} newPage */
const
onChangePage
=
newPage
=>
{
const
onChangePage
=
(
newPage
:
number
)
=>
{
setPaginationPage
(
newPage
);
};
...
...
@@ -113,7 +112,7 @@ function NotebookView({ loadAnnotationsService, streamer }) {
},
[
filters
,
focusedGroup
]);
// Scroll back to here when pagination page changes
const
threadListScrollTop
=
useRef
(
/** @type {HTMLElement|null}*/
(
null
)
);
const
threadListScrollTop
=
useRef
<
HTMLElement
|
null
>
(
null
);
useLayoutEffect
(()
=>
{
// TODO: Transition and effects here should be improved
if
(
paginationPage
!==
lastPaginationPage
.
current
)
{
...
...
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