refactor(popup_editor): better error handling

This commit is contained in:
Elian Doran 2025-07-09 21:56:11 +03:00
parent e7467f6446
commit 5adca76a9a
No known key found for this signature in database

View File

@ -45,20 +45,28 @@ export default class PopupEditorDialog extends Container<BasicWidget> {
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();
if (await this.refresh()) {
openDialog(this.$widget);
}
}
}