From 1b24207e9e770bea1312eb9d099516d379b97393 Mon Sep 17 00:00:00 2001 From: Elian Doran Date: Fri, 18 Apr 2025 10:36:51 +0300 Subject: [PATCH] fix(monorepo/client): error related to blobs --- apps/client/src/services/froca-interface.ts | 2 +- apps/client/src/services/froca.ts | 9 ++++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/apps/client/src/services/froca-interface.ts b/apps/client/src/services/froca-interface.ts index 8d0077989..cfb3d076a 100644 --- a/apps/client/src/services/froca-interface.ts +++ b/apps/client/src/services/froca-interface.ts @@ -11,7 +11,7 @@ export interface Froca { attachments: Record; blobPromises: Record | null>; - getBlob(entityType: string, entityId: string): Promise; + getBlob(entityType: string, entityId: string): Promise; getNote(noteId: string, silentNotFoundError?: boolean): Promise; getNoteFromCache(noteId: string): FNote; getNotesFromCache(noteIds: string[], silentNotFoundError?: boolean): FNote[]; diff --git a/apps/client/src/services/froca.ts b/apps/client/src/services/froca.ts index 8849d6331..c6ad3dc65 100644 --- a/apps/client/src/services/froca.ts +++ b/apps/client/src/services/froca.ts @@ -36,7 +36,7 @@ class FrocaImpl implements Froca { branches!: Record; attributes!: Record; attachments!: Record; - blobPromises!: Record | null>; + blobPromises!: Record | null>; constructor() { this.initializedPromise = this.loadInitialTree(); @@ -368,7 +368,7 @@ class FrocaImpl implements Froca { }); } - async getBlob(entityType: string, entityId: string) { + async getBlob(entityType: string, entityId: string): Promise { // I'm not sure why we're not using blobIds directly, it would save us this composite key ... // perhaps one benefit is that we're always requesting the latest blob, not relying on perhaps faulty/slow // websocket update? @@ -378,7 +378,10 @@ class FrocaImpl implements Froca { this.blobPromises[key] = server .get(`${entityType}/${entityId}/blob`) .then((row) => new FBlob(row)) - .catch((e) => console.error(`Cannot get blob for ${entityType} '${entityId}'`, e)); + .catch((e) => { + console.error(`Cannot get blob for ${entityType} '${entityId}'`, e); + return null; + }); // we don't want to keep large payloads forever in memory, so we clean that up quite quickly // this cache is more meant to share the data between different components within one business transaction (e.g. loading of the note into the tab context and all the components)