A fully open source & end-to-end encrypted note taking alternative to Evernote.
TypeScript asp-net-coredotnet-coreelectronfosshacktoberfestnote-managmentnote-takingnote-taking-appnotebooknotesnotes-appopen-sourceopensourceprivacyproductivityreactreact-nativereactjsself-hosted
fix: handle case where a list with empty notes is searched
thecodrrbf33ee070940
diff --git a/packages/core/__tests__/lookup.test.js b/packages/core/__tests__/lookup.test.jsindex 991ac0e61..4a27f49ff 100644--- a/packages/core/__tests__/lookup.test.js+++ b/packages/core/__tests__/lookup.test.js@@ -31,7 +31,19 @@ test("search notes with a locked note", () =>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");+ let filtered = await db.lookup.notes(db.notes.all, "I am a");+ expect(filtered.length).toBe(1);+ }));++test("search notes with an empty note", () =>+ noteTest({+ content: { delta: [{ insert: "5" }], text: "5" },+ }).then(async ({ db }) => {+ await db.notes.add({+ title: "hello world",+ content: { delta: [], text: "" },+ });+ let filtered = await db.lookup.notes(db.notes.all, "hello world");expect(filtered.length).toBe(1);}));diff --git a/packages/core/api/lookup.js b/packages/core/api/lookup.jsindex d38d64dfd..5a4e509e9 100644--- a/packages/core/api/lookup.js+++ b/packages/core/api/lookup.js@@ -19,9 +19,10 @@ export default class Lookup {let index = 0,max = notes.length;notes.forEach(async (note) => {- const text = note.locked- ? ""- : await this._db.text.get(note.content.text);+ const text =+ note.locked || !note.content+ ? ""+ : 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);