chore(version-snjs): 2.2.0
This commit is contained in:
@@ -7,6 +7,7 @@ import {
|
||||
NoteMutator,
|
||||
ContentType,
|
||||
SNTag,
|
||||
ChallengeReason,
|
||||
} from '@standardnotes/snjs';
|
||||
import {
|
||||
makeObservable,
|
||||
@@ -84,23 +85,6 @@ export class NotesState {
|
||||
return this.application.getTrashedItems().length;
|
||||
}
|
||||
|
||||
async runProtectedAction(action: (note: SNNote) => void, notes: SNNote[]): Promise<void> {
|
||||
let protectedNotesAccessRequest: Promise<boolean>;
|
||||
await Promise.all(
|
||||
notes.map(async (note) => {
|
||||
if (note.protected) {
|
||||
if (!protectedNotesAccessRequest) {
|
||||
protectedNotesAccessRequest =
|
||||
this.application.authorizeNoteAccess(note);
|
||||
}
|
||||
}
|
||||
if (!note.protected || await protectedNotesAccessRequest) {
|
||||
action(note);
|
||||
}
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
async selectNotesRange(selectedNote: SNNote): Promise<void> {
|
||||
const notes = this.application.getDisplayableItems(
|
||||
ContentType.Note
|
||||
@@ -119,10 +103,16 @@ export class NotesState {
|
||||
notesToSelect = notes.slice(selectedNoteIndex, lastSelectedNoteIndex + 1);
|
||||
}
|
||||
|
||||
this.runProtectedAction((note) => {
|
||||
const authorizedNotes =
|
||||
await this.application.authorizeProtectedActionForNotes(
|
||||
notesToSelect,
|
||||
ChallengeReason.SelectProtectedNote
|
||||
);
|
||||
|
||||
for (const note of authorizedNotes) {
|
||||
this.selectedNotes[note.uuid] = note;
|
||||
this.lastSelectedNote = selectedNote;
|
||||
}, notesToSelect);
|
||||
this.lastSelectedNote = note;
|
||||
}
|
||||
}
|
||||
|
||||
async selectNote(uuid: UuidString): Promise<void> {
|
||||
@@ -308,20 +298,14 @@ export class NotesState {
|
||||
}
|
||||
|
||||
async setProtectSelectedNotes(protect: boolean): Promise<void> {
|
||||
const selectedNotes = Object.values(this.selectedNotes);
|
||||
if (protect) {
|
||||
await this.changeSelectedNotes((mutator) => {
|
||||
mutator.protected = protect;
|
||||
});
|
||||
await this.application.protectNotes(selectedNotes);
|
||||
if (!this.application.hasProtectionSources()) {
|
||||
this.setShowProtectedWarning(true);
|
||||
}
|
||||
} else {
|
||||
const selectedNotes = Object.values(this.selectedNotes);
|
||||
this.runProtectedAction(async (note) => {
|
||||
await this.application.changeItem(note.uuid, (mutator) => {
|
||||
mutator.protected = protect;
|
||||
});
|
||||
}, selectedNotes);
|
||||
await this.application.unprotectNotes(selectedNotes);
|
||||
this.setShowProtectedWarning(false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -71,7 +71,7 @@
|
||||
"@reach/checkbox": "^0.13.2",
|
||||
"@reach/dialog": "^0.13.0",
|
||||
"@standardnotes/sncrypto-web": "1.2.10",
|
||||
"@standardnotes/snjs": "2.1.1",
|
||||
"@standardnotes/snjs": "2.2.0",
|
||||
"mobx": "^6.1.6",
|
||||
"mobx-react-lite": "^3.2.0",
|
||||
"preact": "^10.5.12"
|
||||
|
||||
@@ -1936,10 +1936,10 @@
|
||||
"@standardnotes/sncrypto-common" "^1.2.7"
|
||||
libsodium-wrappers "^0.7.8"
|
||||
|
||||
"@standardnotes/snjs@2.1.1":
|
||||
version "2.1.1"
|
||||
resolved "https://registry.yarnpkg.com/@standardnotes/snjs/-/snjs-2.1.1.tgz#789bb492e76ee4fe5816ed0de01c9b774244034d"
|
||||
integrity sha512-GeOPZGX5K2YBdzIWVmS/z4wdQJLLz4Yo2lje8rjep2eLlUiQhRO5BVWaOroYq0uaIamtfSr8m+twbYUkCkPSIQ==
|
||||
"@standardnotes/snjs@2.2.0":
|
||||
version "2.2.0"
|
||||
resolved "https://registry.yarnpkg.com/@standardnotes/snjs/-/snjs-2.2.0.tgz#40a9b840cb2697ad5b2901f4b36767e058a9a259"
|
||||
integrity sha512-VWyjDXZQXFOTFIfCIbCr/4wzcNgoUcpiQRV8eux5NOtZrOZ+buh2H1Mob5hi1Hmgg7wtRS3b1HPf2nx3sRap2Q==
|
||||
dependencies:
|
||||
"@standardnotes/auth" "^2.0.0"
|
||||
"@standardnotes/sncrypto-common" "^1.2.9"
|
||||
|
||||
Reference in New Issue
Block a user