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
{
retryPromiseOperation
}
from
'../util/retry'
;
import
type
{
AnnotationsService
}
from
'./annotations'
;
import
type
{
ToastMessengerService
}
from
'./toast-messenger'
;
/**
/**
* A service for automatically saving new highlights.
* A service for automatically saving new highlights.
...
@@ -6,20 +9,25 @@ import { retryPromiseOperation } from '../util/retry';
...
@@ -6,20 +9,25 @@ import { retryPromiseOperation } from '../util/retry';
* @inject
* @inject
*/
*/
export
class
AutosaveService
{
export
class
AutosaveService
{
/**
private
_annotationsService
:
AnnotationsService
;
* @param {import('./annotations').AnnotationsService} annotationsService
private
_toastMessenger
:
ToastMessengerService
;
* @param {import('./toast-messenger').ToastMessengerService} toastMessenger
private
_store
:
SidebarStore
;
* @param {import('../store').SidebarStore} store
*/
/** A set of annotation $tags that have save requests in-flight */
constructor
(
annotationsService
,
toastMessenger
,
store
)
{
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
.
_annotationsService
=
annotationsService
;
this
.
_toastMessenger
=
toastMessenger
;
this
.
_toastMessenger
=
toastMessenger
;
this
.
_store
=
store
;
this
.
_store
=
store
;
// A set of annotation $tags that have save requests in-flight
this
.
_saving
=
new
Set
();
this
.
_saving
=
new
Set
();
// A set of annotation $tags that have failed to save after retries
this
.
_failed
=
new
Set
();
this
.
_failed
=
new
Set
();
}
}
...
@@ -32,10 +40,9 @@ export class AutosaveService {
...
@@ -32,10 +40,9 @@ export class AutosaveService {
* Determine whether we should try to send a save request for the highlight
* Determine whether we should try to send a save request for the highlight
* indicated by `htag`
* indicated by `htag`
*
*
* @param {string} htag - The local unique identifier for the unsaved highlight
* @param htag - The local unique identifier for the unsaved highlight
* @return {boolean}
*/
*/
const
shouldSaveHighlight
=
htag
=>
{
const
shouldSaveHighlight
=
(
htag
:
string
):
boolean
=>
{
return
!
this
.
_saving
.
has
(
htag
)
&&
!
this
.
_failed
.
has
(
htag
);
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