From 3d9da26bb3d6705604ebf7e4ce19dc7730a65f48 Mon Sep 17 00:00:00 2001 From: Elian Doran Date: Sun, 18 Feb 2024 18:11:56 +0200 Subject: [PATCH 1/2] server-ts: Address review comments --- src/services/erase.js | 2 +- src/services/sync_mutex.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/services/erase.js b/src/services/erase.js index 4c225428b..7ffb30ebc 100644 --- a/src/services/erase.js +++ b/src/services/erase.js @@ -1,6 +1,6 @@ const sql = require("./sql"); const revisionService = require("./revisions.js"); -const log = require("./log.ts"); +const log = require("./log"); const entityChangesService = require("./entity_changes"); const optionService = require("./options"); const dateUtils = require("./date_utils"); diff --git a/src/services/sync_mutex.ts b/src/services/sync_mutex.ts index 655af4d59..9ad0fd08c 100644 --- a/src/services/sync_mutex.ts +++ b/src/services/sync_mutex.ts @@ -6,7 +6,7 @@ const Mutex = require('async-mutex').Mutex; const instance = new Mutex(); -async function doExclusively(func: () => void) { +async function doExclusively(func: () => T) { const releaseMutex = await instance.acquire(); try { From aff1c30557faa7022199d617ba0d9b4d9d5e3471 Mon Sep 17 00:00:00 2001 From: Elian Doran Date: Sun, 18 Feb 2024 20:29:23 +0200 Subject: [PATCH 2/2] server-ts: FIXME -> TODO --- src/becca/entities/abstract_becca_entity.ts | 4 ++-- src/becca/entities/battachment.ts | 4 ++-- src/becca/entities/bblob.ts | 2 +- src/becca/entities/bnote.ts | 4 ++-- src/becca/entities/brevision.ts | 2 +- src/becca/entities/rows.ts | 2 +- src/services/encryption/password.ts | 2 +- src/services/utils.ts | 4 ++-- 8 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/becca/entities/abstract_becca_entity.ts b/src/becca/entities/abstract_becca_entity.ts index 53999be68..74f1163ae 100644 --- a/src/becca/entities/abstract_becca_entity.ts +++ b/src/becca/entities/abstract_becca_entity.ts @@ -89,14 +89,14 @@ abstract class AbstractBeccaEntity> { } hasStringContent(): boolean { - // FIXME: Not sure why some entities don't implement it. + // TODO: Not sure why some entities don't implement it. return true; } abstract getPojo(): {}; get isDeleted(): boolean { - // FIXME: Not sure why some entities don't implement it. + // TODO: Not sure why some entities don't implement it. return false; } diff --git a/src/becca/entities/battachment.ts b/src/becca/entities/battachment.ts index 84f7de5c1..7d90921ab 100644 --- a/src/becca/entities/battachment.ts +++ b/src/becca/entities/battachment.ts @@ -15,7 +15,7 @@ const attachmentRoleToNoteTypeMapping = { }; interface ContentOpts { - // FIXME: Found in bnote.ts, to check if it's actually used and not a typo. + // TODO: Found in bnote.ts, to check if it's actually used and not a typo. forceSave?: boolean; /** will also save this BAttachment entity */ @@ -135,7 +135,7 @@ class BAttachment extends AbstractBeccaEntity { } convertToNote(): { note: BNote, branch: BBranch } { - // FIXME: can this ever be "search"? + // TODO: can this ever be "search"? if (this.type as string === 'search') { throw new Error(`Note of type search cannot have child notes`); } diff --git a/src/becca/entities/bblob.ts b/src/becca/entities/bblob.ts index c37a20581..149b9070a 100644 --- a/src/becca/entities/bblob.ts +++ b/src/becca/entities/bblob.ts @@ -1,6 +1,6 @@ import { BlobRow } from "./rows"; -// FIXME: Why this does not extend the abstract becca? +// TODO: Why this does not extend the abstract becca? class BBlob { static get entityName() { return "blobs"; } static get primaryKeyName() { return "blobId"; } diff --git a/src/becca/entities/bnote.ts b/src/becca/entities/bnote.ts index 26214e608..821e10443 100644 --- a/src/becca/entities/bnote.ts +++ b/src/becca/entities/bnote.ts @@ -216,7 +216,7 @@ class BNote extends AbstractBeccaEntity { * - changes in the note metadata or title should not trigger note content sync (so we keep separate utcDateModified and entity changes records) * - but to the user note content and title changes are one and the same - single dateModified (so all changes must go through Note and content is not a separate entity) */ - // FIXME: original declaration was (string | Buffer), but everywhere it's used as a string. + // TODO: original declaration was (string | Buffer), but everywhere it's used as a string. getContent(): string { return this._getContent() as string; } @@ -900,7 +900,7 @@ class BNote extends AbstractBeccaEntity { const {searchResultNoteIds} = searchService.searchFromNote(this); const becca = this.becca; - return (searchResultNoteIds as string[]) // FIXME: remove cast once search is converted + return (searchResultNoteIds as string[]) // TODO: remove cast once search is converted .map(resultNoteId => becca.notes[resultNoteId]) .filter(note => !!note); } diff --git a/src/becca/entities/brevision.ts b/src/becca/entities/brevision.ts index 43c6631de..9b5e4a410 100644 --- a/src/becca/entities/brevision.ts +++ b/src/becca/entities/brevision.ts @@ -88,7 +88,7 @@ class BRevision extends AbstractBeccaEntity { * * This is the same approach as is used for Note's content. */ - // FIXME: initial declaration included Buffer, but everywhere it's treated as a string. + // TODO: initial declaration included Buffer, but everywhere it's treated as a string. getContent(): string { return this._getContent() as string; } diff --git a/src/becca/entities/rows.ts b/src/becca/entities/rows.ts index c372b30c3..567f14f9f 100644 --- a/src/becca/entities/rows.ts +++ b/src/becca/entities/rows.ts @@ -1,4 +1,4 @@ -// FIXME: Booleans should probably be numbers instead (as SQLite does not have booleans.); +// TODO: Booleans should probably be numbers instead (as SQLite does not have booleans.); export interface AttachmentRow { attachmentId?: string; diff --git a/src/services/encryption/password.ts b/src/services/encryption/password.ts index 266034d35..c14e27700 100644 --- a/src/services/encryption/password.ts +++ b/src/services/encryption/password.ts @@ -31,7 +31,7 @@ function changePassword(currentPassword: string, newPassword: string) { const newPasswordVerificationKey = utils.toBase64(myScryptService.getVerificationHash(newPassword)); if (decryptedDataKey) { - // FIXME: what should happen if the decrypted data key is null? + // TODO: what should happen if the decrypted data key is null? passwordEncryptionService.setDataKey(newPassword, decryptedDataKey); } diff --git a/src/services/utils.ts b/src/services/utils.ts index 4cbb96d2f..dc6129770 100644 --- a/src/services/utils.ts +++ b/src/services/utils.ts @@ -82,7 +82,7 @@ function unescapeHtml(str: string) { } function toObject(array: T[], fn: (item: T) => [K, V]): Record { - const obj: Record = {} as Record; // FIXME: unsafe? + const obj: Record = {} as Record; // TODO: unsafe? for (const item of array) { const ret = fn(item); @@ -98,7 +98,7 @@ function stripTags(text: string) { } function union(a: T[], b: T[]): T[] { - const obj: Record = {} as Record; // FIXME: unsafe? + const obj: Record = {} as Record; // TODO: unsafe? for (let i = a.length-1; i >= 0; i--) { obj[a[i]] = a[i];