fix: allow changing only metadata for locked notes

This commit is contained in:
thecodrr
2022-07-09 23:50:57 +05:00
parent 27dade850a
commit feafb14edd

View File

@@ -252,15 +252,14 @@ export default class Vault {
if (!contentId) throw new Error("Cannot lock note because it is empty."); if (!contentId) throw new Error("Cannot lock note because it is empty.");
// Case: when note is being newly locked // Case: when note is being newly locked
if (!data || !type) { if (!note.locked && (!data || !type)) {
if (note.locked) return;
let content = await this._db.content.raw(contentId, false); let content = await this._db.content.raw(contentId, false);
// NOTE: // NOTE:
// At this point, the note already has all the attachments extracted // At this point, the note already has all the attachments extracted
// so we should just encrypt it as normal. // so we should just encrypt it as normal.
data = content.data; data = content.data;
type = content.type; type = content.type;
} else { } else if (data && type) {
const content = await this._db.content.extractAttachments({ const content = await this._db.content.extractAttachments({
data, data,
type, type,
@@ -270,7 +269,8 @@ export default class Vault {
type = content.type; type = content.type;
} }
await this._encryptContent(contentId, sessionId, data, type, password); if (data && type)
await this._encryptContent(contentId, sessionId, data, type, password);
return await this._db.notes.add({ return await this._db.notes.add({
id, id,