Skip to content

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

fix: crash when search notes that have a locked note

thecodrr544f51c8a93c
diff --git a/packages/core/__tests__/lookup.test.js b/packages/core/__tests__/lookup.test.js
index 059113367..991ac0e61 100644
--- a/packages/core/__tests__/lookup.test.js
+++ b/packages/core/__tests__/lookup.test.js
@@ -24,6 +24,17 @@ test("search notes", () =>
expect(filtered.length).toBe(1);
}));
+test("search notes with a locked note", () =>
+ noteTest({
+ content: { delta: [{ insert: "5" }], text: "5" },
+ }).then(async ({ db }) => {
+ const noteId = await db.notes.add(TEST_NOTE);
+ await db.vault.create("password");
+ await db.vault.add(noteId);
+ let filtered = await db.lookup.notes(db.notes.all, "5");
+ expect(filtered.length).toBe(1);
+ }));
+
test("search notebooks", () =>
notebookTest().then(async ({ db }) => {
await db.notebooks.add(TEST_NOTEBOOK2);
diff --git a/packages/core/api/lookup.js b/packages/core/api/lookup.js
index 0bfb20a8a..d38d64dfd 100644
--- a/packages/core/api/lookup.js
+++ b/packages/core/api/lookup.js
@@ -19,7 +19,9 @@ export default class Lookup {
let index = 0,
max = notes.length;
notes.forEach(async (note) => {
- const text = await this._db.text.get(note.content.text);
+ const text = note.locked
+ ? ""
+ : await this._db.text.get(note.content.text);
const title = note.title;
if (fzs(query, text + title)) results.push(note);
if (++index >= max) return resolve(results);