server-ts: Port services/one_time_timer

This commit is contained in:
Elian Doran 2024-02-18 13:25:18 +02:00
parent 6df09cb157
commit dbccf6b433
No known key found for this signature in database
2 changed files with 4 additions and 4 deletions

View File

@ -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) {

View File

@ -1,4 +1,4 @@
const scheduledExecutions = {};
const scheduledExecutions: Record<string, boolean> = {};
/**
* 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
};