Skip to content

Build your personal knowledge base with Trilium Notes

fix(client): undefined entity in some cases

Elian Dorand684440c1f71
diff --git a/src/public/app/server_types.ts b/src/public/app/server_types.ts
index 2b84596000..df6e1a7fc3 100644
--- a/src/public/app/server_types.ts
+++ b/src/public/app/server_types.ts
@@ -1,12 +1,16 @@
import type { EntityRowNames } from "./services/load_results.js";
+interface Entity {
+ isDeleted?: boolean;
+}
+
// TODO: Deduplicate with src/services/entity_changes_interface.ts
export interface EntityChange {
id?: number | null;
noteId?: string;
entityName: EntityRowNames;
entityId: string;
- entity?: any;
+ entity?: Entity;
positions?: Record<string, number>;
hash: string;
utcDateChanged?: string;
diff --git a/src/public/app/services/froca_updater.ts b/src/public/app/services/froca_updater.ts
index f10720de43..37f9d28142 100644
--- a/src/public/app/services/froca_updater.ts
+++ b/src/public/app/services/froca_updater.ts
@@ -290,14 +290,16 @@ function processAttachment(loadResults: LoadResults, ec: EntityChange) {
return;
}
- if (attachment) {
- attachment.update(ec.entity as FAttachmentRow);
- } else {
- const attachmentRow = ec.entity as FAttachmentRow;
- const note = froca.notes[attachmentRow.ownerId];
+ if (ec.entity) {
+ if (attachment) {
+ attachment.update(ec.entity as FAttachmentRow);
+ } else {
+ const attachmentRow = ec.entity as FAttachmentRow;
+ const note = froca.notes[attachmentRow.ownerId];
- if (note?.attachments) {
- note.attachments.push(new FAttachment(froca, attachmentRow));
+ if (note?.attachments) {
+ note.attachments.push(new FAttachment(froca, attachmentRow));
+ }
}
}