feat: improve note locking/unlocking ux

This commit is contained in:
thecodrr
2020-11-23 15:55:49 +05:00
parent 68ff36ddd3
commit 40e3403387
3 changed files with 16 additions and 12 deletions

View File

@@ -6,7 +6,7 @@ class Vault {
static createVault() {
return showPasswordDialog("create_vault", async ({ password }) => {
await db.vault.create(password);
await showToast("success", "Vault created.");
showToast("success", "Vault created.");
return true;
});
}

View File

@@ -93,10 +93,11 @@ class NoteStore extends BaseStore {
};
unlock = async (id) => {
await Vault.unlockNote(id).then(async () => {
return await Vault.unlockNote(id).then(async (res) => {
if (editorStore.get().session.id === id)
await editorStore.openSession(id);
this.refresh();
return res;
});
};

View File

@@ -297,21 +297,24 @@ function Settings(props) {
Vault
</Text>
{!isVaultCreated && (
<Button variant="list" onClick={Vault.createVault}>
<TextWithTip
text="Create vault"
tip="Create a password-encrypted vault for your notes"
/>
</Button>
)}
{isVaultCreated && (
{isVaultCreated ? (
<>
<Button variant="list" onClick={Vault.changeVaultPassword}>
<TextWithTip text="Change vault password" />
</Button>
</>
) : (
<Button
variant="list"
onClick={async () => {
setIsVaultCreated(await Vault.createVault());
}}
>
<TextWithTip
text="Create vault"
tip="Create a password-encrypted vault for your notes"
/>
</Button>
)}
<Text