From 257d713d39f7e0cd6615dd6898a7e9d1ddeadeb2 Mon Sep 17 00:00:00 2001 From: Baptiste Grob <60621355+baptiste-grob@users.noreply.github.com> Date: Fri, 14 Aug 2020 17:18:41 +0200 Subject: [PATCH] fix: show placeholder note in notes list --- app/assets/javascripts/ui_models/app_state.ts | 4 ++-- app/assets/javascripts/views/notes/notes_view.ts | 11 ++++++++--- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/app/assets/javascripts/ui_models/app_state.ts b/app/assets/javascripts/ui_models/app_state.ts index a24b9e2c6..6d236971b 100644 --- a/app/assets/javascripts/ui_models/app_state.ts +++ b/app/assets/javascripts/ui_models/app_state.ts @@ -87,12 +87,12 @@ export class AppState { * Creates a new editor if one doesn't exist. If one does, we'll replace the * editor's note with an empty one. */ - createEditor(title?: string) { + async createEditor(title?: string) { const activeEditor = this.getActiveEditor(); if (!activeEditor || this.multiEditorEnabled) { this.application.editorGroup.createEditor(undefined, title); } else { - activeEditor.reset(title); + await activeEditor.reset(title); } } diff --git a/app/assets/javascripts/views/notes/notes_view.ts b/app/assets/javascripts/views/notes/notes_view.ts index 182cf5178..86407d73e 100644 --- a/app/assets/javascripts/views/notes/notes_view.ts +++ b/app/assets/javascripts/views/notes/notes_view.ts @@ -243,7 +243,8 @@ class NotesViewCtrl extends PureViewCtrl { } async selectNote(note: SNNote) { - this.appState.openEditor(note.uuid); + await this.appState.openEditor(note.uuid); + this.reloadNotes(); } async createNewNote() { @@ -251,7 +252,8 @@ class NotesViewCtrl extends PureViewCtrl { if (this.isFiltering()) { title = this.getState().noteFilter.text; } - this.appState.createEditor(title); + await this.appState.createEditor(title); + await this.reloadNotes(); } async handleTagChange(tag: SNTag) { @@ -335,8 +337,11 @@ class NotesViewCtrl extends PureViewCtrl { return; } const notes = this.application.getDisplayableItems(ContentType.Note) as SNNote[]; + if (this.appState.getActiveEditor()?.isTemplateNote) { + notes.unshift(this.appState.getActiveEditor()!.note); + } await this.setNotesState({ - notes: notes, + notes, renderedNotes: notes.slice(0, this.notesToDisplay) }); this.reloadPanelTitle();