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
core: fix headline title not updating on every edit (#10512)
Abdullah Attac39b81f8a003
diff --git a/packages/core/__tests__/notes.test.ts b/packages/core/__tests__/notes.test.tsindex b8b7a0419..34edfa76f 100644--- a/packages/core/__tests__/notes.test.ts+++ b/packages/core/__tests__/notes.test.ts@@ -184,6 +184,32 @@ test("note title with headline format should keep generating headline title untiexpect(note?.title).toBe("not delicious anymore");}));+test("note title with headline format should update on every headline change", () =>+ noteTest().then(async ({ db }) => {+ await db.settings.setTitleFormat("$headline$");+ const id = await db.notes.add({+ content: { type: TEST_NOTE.content.type, data: "<p>first</p>" }+ });++ // headline unchanged: should not affect the next title update+ await db.notes.add({+ id,+ content: {+ type: TEST_NOTE.content.type,+ data: "<p>first</p><p>body</p>"+ }+ });+ expect((await db.notes.note(id))?.title).toBe("first");++ for (const headline of ["second", "third", "fourth"]) {+ await db.notes.add({+ id,+ content: { type: TEST_NOTE.content.type, data: `<p>${headline}</p>` }+ });+ expect((await db.notes.note(id))?.title).toBe(headline);+ }+ }));+[["simple p tag", "<p>headline</p>", "headline"],["across multiple tags", "<h1>title</h1><ol><li>list</li></ol>", "title"],diff --git a/packages/core/src/collections/notes.ts b/packages/core/src/collections/notes.tsindex 4f79c42fa..9481e25d0 100644--- a/packages/core/src/collections/notes.ts+++ b/packages/core/src/collections/notes.ts@@ -157,7 +157,7 @@ export class Notes implements ICollection {const titleFormat = this.db.settings.getTitleFormat();if (item.isGeneratedTitle &&- HEADLINE_REGEX.test(titleFormat) &&+ titleFormat.includes("$headline$") &&headlineTitle &¤tNoteTitleFields?.title !== headlineTitle) {