mirror of
https://github.com/zadam/trilium.git
synced 2025-10-20 07:08:55 +02:00
refactor(popup_editor): better error handling
This commit is contained in:
parent
e7467f6446
commit
5adca76a9a
@ -45,20 +45,28 @@ export default class PopupEditorDialog extends Container<BasicWidget> {
|
|||||||
async refresh() {
|
async refresh() {
|
||||||
if (!this.noteId) {
|
if (!this.noteId) {
|
||||||
console.warn("Popup editor noteId is not set, cannot refresh.");
|
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");
|
const noteContext = new NoteContext("_popup-editor");
|
||||||
noteContext.setNote(this.noteId);
|
await noteContext.setNote(note.noteId);
|
||||||
|
|
||||||
this.handleEventInChildren("setNoteContext", {
|
await this.handleEventInChildren("setNoteContext", {
|
||||||
noteContext: noteContext
|
noteContext: noteContext
|
||||||
})
|
});
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
async openPopupEditorEvent(noteId: string) {
|
async openPopupEditorEvent(noteId: string) {
|
||||||
this.noteId = noteId;
|
this.noteId = noteId;
|
||||||
await this.refresh();
|
if (await this.refresh()) {
|
||||||
openDialog(this.$widget);
|
openDialog(this.$widget);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user