mirror of
https://github.com/streetwriters/notesnook.git
synced 2026-02-24 04:00:59 +01:00
core: note title reset on updating a note
This commit is contained in:
@@ -121,6 +121,19 @@ test("setting note title to empty should set the default title", () =>
|
||||
expect(note?.title.startsWith("Note ")).toBe(true);
|
||||
}));
|
||||
|
||||
test("changing content shouldn't reset the note title ", () =>
|
||||
noteTest({ title: "I am a note" }).then(async ({ db, id }) => {
|
||||
await db.notes.add({
|
||||
id,
|
||||
content: {
|
||||
type: TEST_NOTE.content.type,
|
||||
data: "<p>This is a very colorful existence.</p>"
|
||||
}
|
||||
});
|
||||
const note = await db.notes.note(id);
|
||||
expect(note?.title).toBe("I am a note");
|
||||
}));
|
||||
|
||||
test("note should get headline from content", () =>
|
||||
noteTest({
|
||||
...TEST_NOTE,
|
||||
|
||||
@@ -109,17 +109,21 @@ export class Notes implements ICollection {
|
||||
});
|
||||
}
|
||||
|
||||
if (item.title) {
|
||||
if (typeof item.title !== "undefined") {
|
||||
item.title = item.title.replace(NEWLINE_STRIP_REGEX, " ");
|
||||
dateEdited = Date.now();
|
||||
} else {
|
||||
item.title = formatTitle(
|
||||
this.db.settings.getTitleFormat(),
|
||||
this.db.settings.getDateFormat(),
|
||||
this.db.settings.getTimeFormat(),
|
||||
headline?.split(" ").splice(0, 10).join(" ") || "",
|
||||
this.totalNotes
|
||||
);
|
||||
}
|
||||
|
||||
if (!isUpdating || item.title === "") {
|
||||
item.title =
|
||||
item.title ||
|
||||
formatTitle(
|
||||
this.db.settings.getTitleFormat(),
|
||||
this.db.settings.getDateFormat(),
|
||||
this.db.settings.getTimeFormat(),
|
||||
headline?.split(" ").splice(0, 10).join(" ") || "",
|
||||
this.totalNotes
|
||||
);
|
||||
}
|
||||
|
||||
if (isUpdating) {
|
||||
|
||||
Reference in New Issue
Block a user