Skip to content

Build your personal knowledge base with Trilium Notes

refactor: clean up some TODOs

Elian Doran294600da1bab
diff --git a/apps/client/src/services/note_autocomplete.ts b/apps/client/src/services/note_autocomplete.ts
index 56da5c1c62..48aa09c8dd 100644
--- a/apps/client/src/services/note_autocomplete.ts
+++ b/apps/client/src/services/note_autocomplete.ts
@@ -363,8 +363,8 @@ function initNoteAutocomplete($el: JQuery<HTMLElement>, options?: Options) {
]
);
- // TODO: Types fail due to "autocomplete:selected" not being registered in type definitions.
- ($el as any).on("autocomplete:selected", async (event: Event, suggestion: Suggestion) => {
+ //@ts-expect-error The `autocomplete:selected` handler takes an extra `suggestion` argument that jQuery's `.on()` typings don't model.
+ $el.on("autocomplete:selected", async (event: Event, suggestion: Suggestion) => {
if (suggestion.action === "command") {
$el.autocomplete("close");
$el.trigger("autocomplete:commandselected", [suggestion]);
diff --git a/apps/client/src/widgets/type_widgets/relation_map/RelationMap.tsx b/apps/client/src/widgets/type_widgets/relation_map/RelationMap.tsx
index 8a32ffd831..273be1d314 100644
--- a/apps/client/src/widgets/type_widgets/relation_map/RelationMap.tsx
+++ b/apps/client/src/widgets/type_widgets/relation_map/RelationMap.tsx
@@ -304,8 +304,10 @@ async function useRelationData(noteId: string, mapData: MapData | undefined, map
});
if (!connection) return;
- // TODO: Does this actually do anything.
- //@ts-expect-error
+ // Stash the attributeId on the connection so api.ts can map a clicked connection
+ // back to its relation (see the `rel.attributeId === connection.id` lookups there),
+ // and so it can be exposed as data-connection-id below.
+ //@ts-expect-error jsPlumb's Connection type has no writable `id` property.
connection.id = relation.attributeId;
if (relation.type === "inverse") {
diff --git a/apps/server/src/share/shaca/entities/snote.ts b/apps/server/src/share/shaca/entities/snote.ts
index 9c750ea859..d32b7d8df1 100644
--- a/apps/server/src/share/shaca/entities/snote.ts
+++ b/apps/server/src/share/shaca/entities/snote.ts
@@ -388,7 +388,7 @@ class SNote extends AbstractShacaEntity {
getOwnedAttributeValue(type: string, name: string) {
const attr = this.getOwnedAttribute(type, name);
- return attr ? (attr.value as string) : null; // FIXME
+ return attr ? attr.value : null;
}
/**
@@ -404,7 +404,7 @@ class SNote extends AbstractShacaEntity {
* @returns all note's label values, including inherited ones
*/
getLabelValues(name: string) {
- return this.getLabels(name).map((l) => l.value) as string[]; // FIXME
+ return this.getLabels(name).map((l) => l.value);
}
/**
diff --git a/packages/trilium-core/src/becca/entities/abstract_becca_entity.ts b/packages/trilium-core/src/becca/entities/abstract_becca_entity.ts
index dd84718e8f..2a17af5687 100644
--- a/packages/trilium-core/src/becca/entities/abstract_becca_entity.ts
+++ b/packages/trilium-core/src/becca/entities/abstract_becca_entity.ts
@@ -80,7 +80,8 @@ abstract class AbstractBeccaEntity<T extends AbstractBeccaEntity<T>> {
}
hasStringContent(): boolean {
- // TODO: Not sure why some entities don't implement it.
+ // Default for entities without binary content; overridden by content-bearing entities
+ // (BNote, BRevision, BAttachment) whose content may be binary.
return true;
}
@@ -93,7 +94,8 @@ abstract class AbstractBeccaEntity<T extends AbstractBeccaEntity<T>> {
abstract updateFromRow(row: unknown): void;
get isDeleted(): boolean {
- // TODO: Not sure why some entities don't implement it.
+ // Default for entities without a soft-delete column; overridden by those that have one
+ // (BNote, BBranch, BAttribute, BEtapiToken).
return false;
}
diff --git a/packages/trilium-core/src/becca/entities/bblob.ts b/packages/trilium-core/src/becca/entities/bblob.ts
index 7bb05e774f..7163c8e42e 100644
--- a/packages/trilium-core/src/becca/entities/bblob.ts
+++ b/packages/trilium-core/src/becca/entities/bblob.ts
@@ -1,7 +1,6 @@
import AbstractBeccaEntity from "./abstract_becca_entity.js";
import type { BlobRow } from "@triliumnext/commons";
-// TODO: Why this does not extend the abstract becca?
class BBlob extends AbstractBeccaEntity<BBlob> {
static get entityName() {
return "blobs";
diff --git a/packages/trilium-core/src/services/utils/index.ts b/packages/trilium-core/src/services/utils/index.ts
index 1389f54908..b125ffb0bf 100644
--- a/packages/trilium-core/src/services/utils/index.ts
+++ b/packages/trilium-core/src/services/utils/index.ts
@@ -29,7 +29,6 @@ export function isStringNote(type: string | undefined, mime: string) {
return (type && STRING_NOTE_TYPES.has(type)) || mime.startsWith("text/") || STRING_MIME_TYPES.has(mime);
}
-// TODO: Refactor to use getCrypto() directly.
export function randomString(length: number) {
return getCrypto().randomString(length);
}
@@ -410,7 +409,7 @@ export function stripTags(text: string) {
}
export function toObject<T, K extends string | number | symbol, V>(array: T[], fn: (item: T) => [K, V]): Record<K, V> {
- const obj: Record<K, V> = {} as Record<K, V>; // TODO: unsafe?
+ const obj: Record<K, V> = {} as Record<K, V>;
for (const item of array) {
const ret = fn(item);