Skip to content

Commit

Permalink
fix: if multiples notes selected, always select note when clicking on it
Browse files Browse the repository at this point in the history
  • Loading branch information
Antonella Sgarlatta committed May 10, 2021
1 parent a1d636a commit c2ed6f1
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 36 deletions.
2 changes: 1 addition & 1 deletion app/assets/javascripts/components/NotesOptionsPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export const NotesOptionsPanel = observer(({ appState }: Props) => {
onBlur={closeOnBlur}
ref={buttonRef}
className={
'bg-transparent border-solid border-1 border-neutral ' +
'sn-button outlined ' +
'cursor-pointer w-32px h-32px rounded-full p-0 ' +
'flex justify-center items-center'
}
Expand Down
59 changes: 24 additions & 35 deletions app/assets/javascripts/ui_models/app_state/notes_state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,8 @@ export class NotesState {
note.protected && this.application.hasProtectionSources();
if (requestAccess) {
if (!protectedNotesAccessRequest) {
protectedNotesAccessRequest = this.application.authorizeNoteAccess(
note
);
protectedNotesAccessRequest =
this.application.authorizeNoteAccess(note);
}
}
if (!requestAccess || (await protectedNotesAccessRequest)) {
Expand All @@ -129,8 +128,10 @@ export class NotesState {
} else if (this.io.activeModifiers.has(KeyboardModifier.Shift)) {
await this.selectNotesRange(note);
} else {
const shouldSelectNote =
this.selectedNotesCount > 1 || !this.selectedNotes[note.uuid];
if (
!this.selectedNotes[note.uuid] &&
shouldSelectNote &&
(await this.application.authorizeNoteAccess(note))
) {
this.selectedNotes = {
Expand Down Expand Up @@ -183,25 +184,21 @@ export class NotesState {
await this.application.changeItems(
Object.keys(this.selectedNotes),
mutate,
false,
false
);
this.application.sync();
}

setHideSelectedNotePreviews(hide: boolean): void {
this.changeSelectedNotes(
(mutator) => {
mutator.hidePreview = hide;
},
);
this.changeSelectedNotes((mutator) => {
mutator.hidePreview = hide;
});
}

setLockSelectedNotes(lock: boolean): void {
this.changeSelectedNotes(
(mutator) => {
mutator.locked = lock;
},
);
this.changeSelectedNotes((mutator) => {
mutator.locked = lock;
});
}

async setTrashSelectedNotes(trashed: boolean): Promise<void> {
Expand All @@ -214,11 +211,9 @@ export class NotesState {
});
}
} else {
this.changeSelectedNotes(
(mutator) => {
mutator.trashed = trashed;
},
);
this.changeSelectedNotes((mutator) => {
mutator.trashed = trashed;
});
this.unselectNotes();
this.contextMenuOpen = false;
}
Expand Down Expand Up @@ -263,11 +258,9 @@ export class NotesState {
await this.application.deleteItem(note);
}
} else {
this.changeSelectedNotes(
(mutator) => {
mutator.trashed = true;
},
);
this.changeSelectedNotes((mutator) => {
mutator.trashed = true;
});
}
return true;
}
Expand All @@ -276,11 +269,9 @@ export class NotesState {
}

setPinSelectedNotes(pinned: boolean): void {
this.changeSelectedNotes(
(mutator) => {
mutator.pinned = pinned;
},
);
this.changeSelectedNotes((mutator) => {
mutator.pinned = pinned;
});
}

async setArchiveSelectedNotes(archived: boolean): Promise<void> {
Expand All @@ -291,11 +282,9 @@ export class NotesState {
return;
}

this.changeSelectedNotes(
(mutator) => {
mutator.archived = archived;
},
);
this.changeSelectedNotes((mutator) => {
mutator.archived = archived;
});

runInAction(() => {
this.selectedNotes = {};
Expand Down

0 comments on commit c2ed6f1

Please sign in to comment.