refactor: pass note as parameter to selectNote
This commit is contained in:
@@ -7,7 +7,6 @@ import {
|
|||||||
NoteMutator,
|
NoteMutator,
|
||||||
ContentType,
|
ContentType,
|
||||||
SNTag,
|
SNTag,
|
||||||
SNItem,
|
|
||||||
} from '@standardnotes/snjs';
|
} from '@standardnotes/snjs';
|
||||||
import {
|
import {
|
||||||
makeObservable,
|
makeObservable,
|
||||||
@@ -115,17 +114,16 @@ export class NotesState {
|
|||||||
this.lastSelectedNote = selectedNote;
|
this.lastSelectedNote = selectedNote;
|
||||||
}
|
}
|
||||||
|
|
||||||
async selectNote(uuid: UuidString): Promise<void> {
|
async selectNote(note: SNNote): Promise<void> {
|
||||||
const note = this.application.findItem(uuid) as SNNote;
|
|
||||||
if (
|
if (
|
||||||
this.io.activeModifiers.has(
|
this.io.activeModifiers.has(
|
||||||
KeyboardModifier.Meta || KeyboardModifier.Ctrl
|
KeyboardModifier.Meta || KeyboardModifier.Ctrl
|
||||||
)
|
)
|
||||||
) {
|
) {
|
||||||
if (this.selectedNotes[uuid]) {
|
if (this.selectedNotes[note.uuid]) {
|
||||||
delete this.selectedNotes[uuid];
|
delete this.selectedNotes[note.uuid];
|
||||||
} else if (await this.application.authorizeNoteAccess(note)) {
|
} else if (await this.application.authorizeNoteAccess(note)) {
|
||||||
this.selectedNotes[uuid] = note;
|
this.selectedNotes[note.uuid] = note;
|
||||||
this.lastSelectedNote = note;
|
this.lastSelectedNote = note;
|
||||||
}
|
}
|
||||||
} else if (this.io.activeModifiers.has(KeyboardModifier.Shift)) {
|
} else if (this.io.activeModifiers.has(KeyboardModifier.Shift)) {
|
||||||
@@ -133,9 +131,9 @@ export class NotesState {
|
|||||||
} else {
|
} else {
|
||||||
if (await this.application.authorizeNoteAccess(note)) {
|
if (await this.application.authorizeNoteAccess(note)) {
|
||||||
this.selectedNotes = {
|
this.selectedNotes = {
|
||||||
[uuid]: note,
|
[note.uuid]: note,
|
||||||
};
|
};
|
||||||
await this.openEditor(uuid);
|
await this.openEditor(note.uuid);
|
||||||
this.lastSelectedNote = note;
|
this.lastSelectedNote = note;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -355,7 +355,7 @@ class NotesViewCtrl extends PureViewCtrl<unknown, NotesCtrlState> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async selectNote(note: SNNote): Promise<void> {
|
async selectNote(note: SNNote): Promise<void> {
|
||||||
await this.appState.notes.selectNote(note.uuid);
|
await this.appState.notes.selectNote(note);
|
||||||
}
|
}
|
||||||
|
|
||||||
async createNewNote() {
|
async createNewNote() {
|
||||||
|
|||||||
Reference in New Issue
Block a user