feat: make unprotecting a note a protected action

This commit is contained in:
Baptiste Grob
2021-02-23 10:40:08 +01:00
parent ef3a962d78
commit a3f73ba664
3 changed files with 17 additions and 19 deletions

View File

@@ -714,20 +714,18 @@ class EditorViewCtrl extends PureViewCtrl<unknown, EditorState> {
}
async toggleProtectNote() {
const note = await this.application.changeAndSaveItem<NoteMutator>(
this.note.uuid,
(mutator) => {
mutator.protected = !this.note.protected;
},
false
);
if (note?.protected && !this.application.hasProtectionSources()) {
if (await confirmDialog({
text: Strings.protectingNoteWithoutProtectionSources,
confirmButtonText: Strings.openAccountMenu,
confirmButtonStyle: 'info',
})) {
this.appState.accountMenu.setShow(true);
if (this.note.protected) {
void this.application.unprotectNote(this.note);
} else {
const note = await this.application.protectNote(this.note);
if (note?.protected && !this.application.hasProtectionSources()) {
if (await confirmDialog({
text: Strings.protectingNoteWithoutProtectionSources,
confirmButtonText: Strings.openAccountMenu,
confirmButtonStyle: 'info',
})) {
this.appState.accountMenu.setShow(true);
}
}
}
}

View File

@@ -68,7 +68,7 @@
"@reach/alert-dialog": "^0.13.0",
"@reach/dialog": "^0.13.0",
"@standardnotes/sncrypto-web": "^1.2.10",
"@standardnotes/snjs": "^2.0.57",
"@standardnotes/snjs": "^2.0.58",
"mobx": "^6.1.6",
"preact": "^10.5.12"
}

View File

@@ -1845,10 +1845,10 @@
"@standardnotes/sncrypto-common" "^1.2.7"
libsodium-wrappers "^0.7.8"
"@standardnotes/snjs@^2.0.57":
version "2.0.57"
resolved "https://registry.yarnpkg.com/@standardnotes/snjs/-/snjs-2.0.57.tgz#758d30d9074aa463ca2b642783d929a10a1a1c9f"
integrity sha512-s2FP024TziZnt0nJ10Tbja3IQ2KOITA67EGchadAN+vapXEicTDX2MSCPzlvk2D1M494zu15vWwQX1ryeHvHHA==
"@standardnotes/snjs@^2.0.58":
version "2.0.58"
resolved "https://registry.yarnpkg.com/@standardnotes/snjs/-/snjs-2.0.58.tgz#b3cc340699effd9ab2b55e48eb84745f71e058cb"
integrity sha512-eJnCpwTpI55RM916xjdgcGdzIcgaGJQ5EeykKvLxD4Oy7FRPfQnZc5hCp4LbeZvdlQQze+E2gH1nY77zPDsVXw==
dependencies:
"@standardnotes/sncrypto-common" "^1.2.9"