Skip to content

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

fix: collection map not being updated

thecodrr4928de3face6
diff --git a/packages/core/collections/notebooks.js b/packages/core/collections/notebooks.js
index 6317f2c5c..26264d2ed 100644
--- a/packages/core/collections/notebooks.js
+++ b/packages/core/collections/notebooks.js
@@ -89,7 +89,7 @@ export default class Notebooks {
await this._collection.transaction(() =>
notebook.topics.delete(...notebook.data.topics)
);
- await this._collection.removeItem(id);
+ await this._collection.removeIndex(id);
await this._trash.add(notebook.data);
}
}
diff --git a/packages/core/collections/notes.js b/packages/core/collections/notes.js
index 21267b119..6729e0bdf 100644
--- a/packages/core/collections/notes.js
+++ b/packages/core/collections/notes.js
@@ -216,7 +216,7 @@ export default class Notes {
for (let color of item.colors) {
await this._colorsCollection.remove(color);
}
- await this._collection.removeItem(id);
+ await this._collection.removeIndex(id);
await this._trash.add(item.data);
}
}
diff --git a/packages/core/collections/trash.js b/packages/core/collections/trash.js
index 188ab8001..ca28fd5f3 100644
--- a/packages/core/collections/trash.js
+++ b/packages/core/collections/trash.js
@@ -103,7 +103,7 @@ export default class Trash {
if (topic.notes) await t.add(...topic.notes);
}
}
- await this._collection.indexer.deindex(id); // we only deindex
+ await this._collection.removeIndex(id); // we only deindex
}
}
diff --git a/packages/core/database/cached-collection.js b/packages/core/database/cached-collection.js
index a0a77b83f..0685d16b0 100644
--- a/packages/core/database/cached-collection.js
+++ b/packages/core/database/cached-collection.js
@@ -50,8 +50,13 @@ export default class CachedCollection {
async removeItem(id) {
if (this.transactionOpen) return;
- await this.indexer.deindex(id);
await this.indexer.remove(id);
+ await this.removeIndex(id);
+ }
+
+ async removeIndex(id) {
+ if (!id) return;
+ await this.indexer.deindex(id);
this.map.delete(id);
}