mirror of
https://github.com/zadam/trilium.git
synced 2025-03-01 14:22:32 +01:00
server-ts: Port services/spaced_update
This commit is contained in:
parent
915de23e34
commit
16283d4054
@ -15,7 +15,7 @@ const searchService = require('./search/services/search');
|
||||
const SearchContext = require('./search/search_context');
|
||||
const becca = require('../becca/becca');
|
||||
const ws = require('./ws');
|
||||
const SpacedUpdate = require('./spaced_update.js');
|
||||
const SpacedUpdate = require('./spaced_update');
|
||||
const specialNotesService = require('./special_notes.js');
|
||||
const branchService = require('./branches');
|
||||
const exportService = require('./export/zip');
|
||||
|
@ -1,9 +1,19 @@
|
||||
type Updater = () => void;
|
||||
|
||||
class SpacedUpdate {
|
||||
constructor(updater, updateInterval = 1000) {
|
||||
|
||||
private updater: Updater;
|
||||
private lastUpdated: number;
|
||||
private changed: boolean;
|
||||
private updateInterval: number;
|
||||
private changeForbidden: boolean;
|
||||
|
||||
constructor(updater: Updater, updateInterval = 1000) {
|
||||
this.updater = updater;
|
||||
this.lastUpdated = Date.now();
|
||||
this.changed = false;
|
||||
this.updateInterval = updateInterval;
|
||||
this.changeForbidden = false;
|
||||
}
|
||||
|
||||
scheduleUpdate() {
|
||||
@ -52,7 +62,7 @@ class SpacedUpdate {
|
||||
}
|
||||
}
|
||||
|
||||
async allowUpdateWithoutChange(callback) {
|
||||
async allowUpdateWithoutChange(callback: () => void) {
|
||||
this.changeForbidden = true;
|
||||
|
||||
try {
|
||||
@ -64,4 +74,4 @@ class SpacedUpdate {
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = SpacedUpdate;
|
||||
export = SpacedUpdate;
|
Loading…
x
Reference in New Issue
Block a user