Skip to content

Commit

Permalink
feat: make unprotecting a note a protected action
Browse files Browse the repository at this point in the history
  • Loading branch information
arielsvg committed Feb 23, 2021
1 parent ef3a962 commit a3f73ba
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 19 deletions.
26 changes: 12 additions & 14 deletions app/assets/javascripts/views/editor/editor_view.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down

0 comments on commit a3f73ba

Please sign in to comment.