Skip to content

A fully open source & end-to-end encrypted note taking alternative to Evernote.

fix: delete item from trash when restoring

thecodrr37acc7cac525
diff --git a/packages/core/__tests__/database.test.js b/packages/core/__tests__/database.test.js
index ceb2816cd..39ea31786 100644
--- a/packages/core/__tests__/database.test.js
+++ b/packages/core/__tests__/database.test.js
@@ -384,6 +384,8 @@ test("restore an item from trash", () =>
let trash = db.getTrash();
expect(trash.length).toBeGreaterThan(0);
await db.restoreItem(timestamp);
+ trash = db.getTrash();
+ expect(trash.length).toBe(0);
let notebook = db.getNotebook(timestamp);
expect(notebook.dateCreated).toBe(timestamp);
}));
diff --git a/packages/core/api/database.js b/packages/core/api/database.js
index 804decf49..255d08219 100644
--- a/packages/core/api/database.js
+++ b/packages/core/api/database.js
@@ -426,6 +426,8 @@ class Database {
delete this.trash[id].dType;
let item = this.trash[id];
this[type][id] = item;
+ delete this.trash[id];
+ await this.storage.write(KEYS.trash, this.trash);
await this.storage.write(type, this[type]);
}