From df5327e638d5c3c46ccf539edfae5ca4d73870f7 Mon Sep 17 00:00:00 2001 From: Antonella Sgarlatta Date: Mon, 10 May 2021 16:25:43 -0300 Subject: [PATCH] refactor: pass note as parameter to selectNote --- .../javascripts/ui_models/app_state/notes_state.ts | 14 ++++++-------- app/assets/javascripts/views/notes/notes_view.ts | 2 +- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/app/assets/javascripts/ui_models/app_state/notes_state.ts b/app/assets/javascripts/ui_models/app_state/notes_state.ts index d8c5c2814..d29ea33a9 100644 --- a/app/assets/javascripts/ui_models/app_state/notes_state.ts +++ b/app/assets/javascripts/ui_models/app_state/notes_state.ts @@ -7,7 +7,6 @@ import { NoteMutator, ContentType, SNTag, - SNItem, } from '@standardnotes/snjs'; import { makeObservable, @@ -115,17 +114,16 @@ export class NotesState { this.lastSelectedNote = selectedNote; } - async selectNote(uuid: UuidString): Promise { - const note = this.application.findItem(uuid) as SNNote; + async selectNote(note: SNNote): Promise { if ( this.io.activeModifiers.has( KeyboardModifier.Meta || KeyboardModifier.Ctrl ) ) { - if (this.selectedNotes[uuid]) { - delete this.selectedNotes[uuid]; + if (this.selectedNotes[note.uuid]) { + delete this.selectedNotes[note.uuid]; } else if (await this.application.authorizeNoteAccess(note)) { - this.selectedNotes[uuid] = note; + this.selectedNotes[note.uuid] = note; this.lastSelectedNote = note; } } else if (this.io.activeModifiers.has(KeyboardModifier.Shift)) { @@ -133,9 +131,9 @@ export class NotesState { } else { if (await this.application.authorizeNoteAccess(note)) { this.selectedNotes = { - [uuid]: note, + [note.uuid]: note, }; - await this.openEditor(uuid); + await this.openEditor(note.uuid); this.lastSelectedNote = note; } } diff --git a/app/assets/javascripts/views/notes/notes_view.ts b/app/assets/javascripts/views/notes/notes_view.ts index bd36b98d9..743c859c5 100644 --- a/app/assets/javascripts/views/notes/notes_view.ts +++ b/app/assets/javascripts/views/notes/notes_view.ts @@ -355,7 +355,7 @@ class NotesViewCtrl extends PureViewCtrl { } async selectNote(note: SNNote): Promise { - await this.appState.notes.selectNote(note.uuid); + await this.appState.notes.selectNote(note); } async createNewNote() {