fix: always create a template note
This commit is contained in:
@@ -7,7 +7,7 @@ export class Editor {
|
|||||||
private application: WebApplication
|
private application: WebApplication
|
||||||
private _onNoteChange?: () => void
|
private _onNoteChange?: () => void
|
||||||
private _onNoteValueChange?: (note: SNNote, source?: PayloadSource) => void
|
private _onNoteValueChange?: (note: SNNote, source?: PayloadSource) => void
|
||||||
private removeStreamObserver: () => void
|
private removeStreamObserver?: () => void
|
||||||
public isTemplateNote = false
|
public isTemplateNote = false
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
@@ -18,10 +18,15 @@ export class Editor {
|
|||||||
this.application = application;
|
this.application = application;
|
||||||
if (noteUuid) {
|
if (noteUuid) {
|
||||||
this.note = application.findItem(noteUuid) as SNNote;
|
this.note = application.findItem(noteUuid) as SNNote;
|
||||||
|
this.streamItems();
|
||||||
} else {
|
} else {
|
||||||
this.reset(noteTitle);
|
this.reset(noteTitle)
|
||||||
|
.then(() => this.streamItems())
|
||||||
|
.catch(console.error);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private streamItems() {
|
||||||
this.removeStreamObserver = this.application.streamItems(
|
this.removeStreamObserver = this.application.streamItems(
|
||||||
ContentType.Note,
|
ContentType.Note,
|
||||||
async (items, source) => {
|
async (items, source) => {
|
||||||
@@ -31,7 +36,7 @@ export class Editor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
deinit() {
|
deinit() {
|
||||||
this.removeStreamObserver();
|
this.removeStreamObserver?.();
|
||||||
(this.removeStreamObserver as any) = undefined;
|
(this.removeStreamObserver as any) = undefined;
|
||||||
this._onNoteChange = undefined;
|
this._onNoteChange = undefined;
|
||||||
(this.application as any) = undefined;
|
(this.application as any) = undefined;
|
||||||
|
|||||||
Reference in New Issue
Block a user