From 5adca76a9ab1b2fdd92890d1361a2f82cd82e39f Mon Sep 17 00:00:00 2001 From: Elian Doran Date: Wed, 9 Jul 2025 21:56:11 +0300 Subject: [PATCH] refactor(popup_editor): better error handling --- .../src/widgets/dialogs/popup_editor.ts | 20 +++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/apps/client/src/widgets/dialogs/popup_editor.ts b/apps/client/src/widgets/dialogs/popup_editor.ts index 6e9c34e99..eb543c3ed 100644 --- a/apps/client/src/widgets/dialogs/popup_editor.ts +++ b/apps/client/src/widgets/dialogs/popup_editor.ts @@ -45,20 +45,28 @@ export default class PopupEditorDialog extends Container { async refresh() { if (!this.noteId) { console.warn("Popup editor noteId is not set, cannot refresh."); - return; + return false; + } + + const note = await froca.getNote(this.noteId); + if (!note) { + console.warn(`Popup editor note with ID ${this.noteId} not found.`); + return false; } const noteContext = new NoteContext("_popup-editor"); - noteContext.setNote(this.noteId); + await noteContext.setNote(note.noteId); - this.handleEventInChildren("setNoteContext", { + await this.handleEventInChildren("setNoteContext", { noteContext: noteContext - }) + }); + return true; } async openPopupEditorEvent(noteId: string) { this.noteId = noteId; - await this.refresh(); - openDialog(this.$widget); + if (await this.refresh()) { + openDialog(this.$widget); + } } }