refactor: pass note as parameter to selectNote

This commit is contained in:
Antonella Sgarlatta
2021-05-10 16:25:43 -03:00
parent f317d6cb7c
commit df5327e638
2 changed files with 7 additions and 9 deletions

View File

@@ -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<void> {
const note = this.application.findItem(uuid) as SNNote;
async selectNote(note: SNNote): Promise<void> {
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;
}
}

View File

@@ -355,7 +355,7 @@ class NotesViewCtrl extends PureViewCtrl<unknown, NotesCtrlState> {
}
async selectNote(note: SNNote): Promise<void> {
await this.appState.notes.selectNote(note.uuid);
await this.appState.notes.selectNote(note);
}
async createNewNote() {