From dbccf6b43348131f8e9bb47a7ee232313e760eb4 Mon Sep 17 00:00:00 2001 From: Elian Doran Date: Sun, 18 Feb 2024 13:25:18 +0200 Subject: [PATCH] server-ts: Port services/one_time_timer --- src/services/handlers.js | 2 +- src/services/{one_time_timer.js => one_time_timer.ts} | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) rename src/services/{one_time_timer.js => one_time_timer.ts} (77%) diff --git a/src/services/handlers.js b/src/services/handlers.js index 16cdd7733..11c9ef5fe 100644 --- a/src/services/handlers.js +++ b/src/services/handlers.js @@ -5,7 +5,7 @@ const noteService = require('./notes'); const becca = require('../becca/becca'); const BAttribute = require('../becca/entities/battribute'); const hiddenSubtreeService = require('./hidden_subtree'); -const oneTimeTimer = require('./one_time_timer.js'); +const oneTimeTimer = require('./one_time_timer'); function runAttachedRelations(note, relationName, originEntity) { if (!note) { diff --git a/src/services/one_time_timer.js b/src/services/one_time_timer.ts similarity index 77% rename from src/services/one_time_timer.js rename to src/services/one_time_timer.ts index 648c250bb..033a8b3c1 100644 --- a/src/services/one_time_timer.js +++ b/src/services/one_time_timer.ts @@ -1,4 +1,4 @@ -const scheduledExecutions = {}; +const scheduledExecutions: Record = {}; /** * Subsequent calls will not move the timer to the future. The first caller determines the time of execution. @@ -6,7 +6,7 @@ const scheduledExecutions = {}; * The good thing about synchronous better-sqlite3 is that this cannot interrupt transaction. The execution will be called * only outside of a transaction. */ -function scheduleExecution(name, milliseconds, cb) { +function scheduleExecution(name: string, milliseconds: number, cb: () => void) { if (name in scheduledExecutions) { return; } @@ -20,6 +20,6 @@ function scheduleExecution(name, milliseconds, cb) { }, milliseconds); } -module.exports = { +export = { scheduleExecution };