Skip to content

Commit

Permalink
Merge branch 'develop' into feature/autocomplete-tags
Browse files Browse the repository at this point in the history
  • Loading branch information
Antonella Sgarlatta committed Jun 2, 2021
2 parents 54fbb60 + 2750435 commit ba1f151
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
12 changes: 8 additions & 4 deletions app/assets/javascripts/ui_models/app_state/notes_state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,13 +110,14 @@ export class NotesState {
}
}

async selectNote(uuid: UuidString): Promise<void> {
async selectNote(uuid: UuidString, userTriggered?: boolean): Promise<void> {
const note = this.application.findItem(uuid) as SNNote;

if (note) {
if (
this.io.activeModifiers.has(KeyboardModifier.Meta) ||
this.io.activeModifiers.has(KeyboardModifier.Ctrl)
userTriggered &&
(this.io.activeModifiers.has(KeyboardModifier.Meta) ||
this.io.activeModifiers.has(KeyboardModifier.Ctrl))
) {
if (this.selectedNotes[uuid]) {
delete this.selectedNotes[uuid];
Expand All @@ -126,7 +127,10 @@ export class NotesState {
this.lastSelectedNote = note;
});
}
} else if (this.io.activeModifiers.has(KeyboardModifier.Shift)) {
} else if (
userTriggered &&
this.io.activeModifiers.has(KeyboardModifier.Shift)
) {
await this.selectNotesRange(note);
} else {
const shouldSelectNote =
Expand Down
2 changes: 1 addition & 1 deletion app/assets/javascripts/views/notes/notes-view.pug
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@
ng-attr-id='note-{{note.uuid}}'
ng-repeat='note in self.state.renderedNotes track by note.uuid'
ng-class="{'selected' : self.isNoteSelected(note.uuid) }"
ng-click='self.selectNote(note)'
ng-click='self.selectNote(note, true)'
)
.note-flags(ng-show='self.noteFlags[note.uuid].length > 0')
.flag(ng-class='flag.class', ng-repeat='flag in self.noteFlags[note.uuid]')
Expand Down
6 changes: 3 additions & 3 deletions app/assets/javascripts/views/notes/notes_view.ts
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ class NotesViewCtrl extends PureViewCtrl<unknown, NotesCtrlState> {
private async openNotesContextMenu(e: MouseEvent, note: SNNote) {
e.preventDefault();
if (!this.state.selectedNotes[note.uuid]) {
await this.selectNote(note);
await this.selectNote(note, true);
}
if (this.state.selectedNotes[note.uuid]) {
const { clientHeight } = document.documentElement;
Expand Down Expand Up @@ -397,8 +397,8 @@ class NotesViewCtrl extends PureViewCtrl<unknown, NotesCtrlState> {
}
}

async selectNote(note: SNNote): Promise<void> {
await this.appState.notes.selectNote(note.uuid);
async selectNote(note: SNNote, userTriggered?: boolean): Promise<void> {
await this.appState.notes.selectNote(note.uuid, userTriggered);
}

async createNewNote() {
Expand Down

0 comments on commit ba1f151

Please sign in to comment.