core: don't generate headline title if title was set during note creation (#8266)

Signed-off-by: 01zulfi <85733202+01zulfi@users.noreply.github.com>
This commit is contained in:
01zulfi
2025-06-27 11:50:43 +05:00
committed by Abdullah Atta
parent a165675b2a
commit deb507859a
2 changed files with 15 additions and 1 deletions

View File

@@ -205,6 +205,20 @@ test("note title with headline format should keep generating headline title unti
}));
});
test("note title with headline format should not generate headline title if title was set during note creation", () =>
noteTest({ title: "already set title" }).then(async ({ db, id }) => {
await db.settings.setTitleFormat("$headline$");
await db.notes.add({
id,
content: {
type: TEST_NOTE.content.type,
data: "<p>some note content</p>"
}
});
const note = await db.notes.note(id);
expect(note?.title).toBe("already set title");
}));
test("note should get headline from first paragraph in content", () =>
noteTest({
...TEST_NOTE,

View File

@@ -130,6 +130,7 @@ export class Notes implements ICollection {
}
if (!isUpdating || item.title === "") {
item.isGeneratedTitle = !Boolean(item.title);
item.title =
item.title ||
formatTitle(
@@ -139,7 +140,6 @@ export class Notes implements ICollection {
headlineTitle,
this.totalNotes
);
item.isGeneratedTitle = true;
}
const currentNoteTitleFields = await this.db