fix: correctly select displayable note

This commit is contained in:
Baptiste Grob
2020-08-18 17:32:50 +02:00
parent fd26bde812
commit 5bd35a5797

View File

@@ -337,12 +337,15 @@ class NotesViewCtrl extends PureViewCtrl {
return;
}
const notes = this.application.getDisplayableItems(ContentType.Note) as SNNote[];
let renderedNotes: SNNote[];
if (this.appState.getActiveEditor()?.isTemplateNote) {
notes.unshift(this.appState.getActiveEditor()!.note);
renderedNotes = [this.appState.getActiveEditor().note, ...notes.slice(0, this.notesToDisplay)];
} else {
renderedNotes = notes.slice(0, this.notesToDisplay);
}
await this.setNotesState({
notes,
renderedNotes: notes.slice(0, this.notesToDisplay)
renderedNotes,
});
this.reloadPanelTitle();
}
@@ -572,16 +575,7 @@ class NotesViewCtrl extends PureViewCtrl {
getFirstNonProtectedNote() {
const displayableNotes = this.displayableNotes();
let index = 0;
let note = displayableNotes[index];
while (note && note.protected) {
index++;
if (index >= displayableNotes.length) {
break;
}
note = displayableNotes[index];
}
return note;
return displayableNotes.find(note => !note.protected);
}
selectFirstNote() {