Skip to content

Commit

Permalink
fix: always create a template note
Browse files Browse the repository at this point in the history
  • Loading branch information
arielsvg committed Aug 14, 2020
1 parent 8bd2f0e commit 27ec6f9
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions app/assets/javascripts/ui_models/editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export class Editor {
private application: WebApplication
private _onNoteChange?: () => void
private _onNoteValueChange?: (note: SNNote, source?: PayloadSource) => void
private removeStreamObserver: () => void
private removeStreamObserver?: () => void
public isTemplateNote = false

constructor(
Expand All @@ -18,10 +18,15 @@ export class Editor {
this.application = application;
if (noteUuid) {
this.note = application.findItem(noteUuid) as SNNote;
this.streamItems();
} else {
this.reset(noteTitle);
this.reset(noteTitle)
.then(() => this.streamItems())
.catch(console.error);
}
}

private streamItems() {
this.removeStreamObserver = this.application.streamItems(
ContentType.Note,
async (items, source) => {
Expand All @@ -31,7 +36,7 @@ export class Editor {
}

deinit() {
this.removeStreamObserver();
this.removeStreamObserver?.();
(this.removeStreamObserver as any) = undefined;
this._onNoteChange = undefined;
(this.application as any) = undefined;
Expand Down

0 comments on commit 27ec6f9

Please sign in to comment.