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