core: fix vault key not getting synced

This commit is contained in:
Abdullah Atta
2023-10-02 15:09:28 +05:00
committed by Abdullah Atta
parent 4a557c67b7
commit 7b08b5c035
2 changed files with 11 additions and 6 deletions

View File

@@ -263,12 +263,14 @@ class Sync {
lastSynced
);
if (serverResponse.vaultKey) {
await this.merger.mergeItem(
"vaultKey",
serverResponse.vaultKey,
serverResponse.lastSynced
);
if (
serverResponse.vaultKey &&
serverResponse.vaultKey.cipher !== null &&
serverResponse.vaultKey.iv !== null &&
serverResponse.vaultKey.salt !== null &&
serverResponse.vaultKey.length > 0
) {
await this.db.vault._setKey(serverResponse.vaultKey);
}
this.connection.off("SendItems");

View File

@@ -179,6 +179,8 @@ export default class Vault {
const note = this._db.notes.note(noteId);
if (!note) return;
await this._unlockNote(note.data, password, true);
if (!this.exists()) await this.create(password);
}
/**
@@ -192,6 +194,7 @@ export default class Vault {
const unlockedNote = await this._unlockNote(note.data, password, false);
this._password = password;
if (!this.exists()) await this.create(this._password);
return unlockedNote;
}