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
1dc1d20d
Commit
1dc1d20d
authored
Mar 13, 2023
by
Alejandro Celaya
Committed by
Alejandro Celaya
Mar 13, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Migrate AutosaveService to TypeScript
parent
c7933df2
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
12 deletions
+19
-12
autosave.ts
src/sidebar/services/autosave.ts
+19
-12
No files found.
src/sidebar/services/autosave.
j
s
→
src/sidebar/services/autosave.
t
s
View file @
1dc1d20d
import
type
{
SidebarStore
}
from
'../store'
;
import
{
retryPromiseOperation
}
from
'../util/retry'
;
import
type
{
AnnotationsService
}
from
'./annotations'
;
import
type
{
ToastMessengerService
}
from
'./toast-messenger'
;
/**
* A service for automatically saving new highlights.
...
...
@@ -6,20 +9,25 @@ import { retryPromiseOperation } from '../util/retry';
* @inject
*/
export
class
AutosaveService
{
/**
* @param {import('./annotations').AnnotationsService} annotationsService
* @param {import('./toast-messenger').ToastMessengerService} toastMessenger
* @param {import('../store').SidebarStore} store
*/
constructor
(
annotationsService
,
toastMessenger
,
store
)
{
private
_annotationsService
:
AnnotationsService
;
private
_toastMessenger
:
ToastMessengerService
;
private
_store
:
SidebarStore
;
/** A set of annotation $tags that have save requests in-flight */
private
_saving
:
Set
<
string
>
;
/** A set of annotation $tags that have failed to save after retries */
private
_failed
:
Set
<
string
>
;
constructor
(
annotationsService
:
AnnotationsService
,
toastMessenger
:
ToastMessengerService
,
store
:
SidebarStore
)
{
this
.
_annotationsService
=
annotationsService
;
this
.
_toastMessenger
=
toastMessenger
;
this
.
_store
=
store
;
// A set of annotation $tags that have save requests in-flight
this
.
_saving
=
new
Set
();
// A set of annotation $tags that have failed to save after retries
this
.
_failed
=
new
Set
();
}
...
...
@@ -32,10 +40,9 @@ export class AutosaveService {
* Determine whether we should try to send a save request for the highlight
* indicated by `htag`
*
* @param {string} htag - The local unique identifier for the unsaved highlight
* @return {boolean}
* @param htag - The local unique identifier for the unsaved highlight
*/
const
shouldSaveHighlight
=
htag
=>
{
const
shouldSaveHighlight
=
(
htag
:
string
):
boolean
=>
{
return
!
this
.
_saving
.
has
(
htag
)
&&
!
this
.
_failed
.
has
(
htag
);
};
...
...
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