core: do not allow empty titles

This commit is contained in:
Abdullah Atta
2025-05-22 11:20:44 +05:00
parent b5e589ab2e
commit 42e4238aa1

View File

@@ -145,8 +145,7 @@ export class Notes implements ICollection {
const currentNoteTitleFields = await this.db
.sql()
.selectFrom("notes")
.select("isGeneratedTitle")
.select("title")
.select(["isGeneratedTitle", "title"])
.where("id", "=", id)
.executeTakeFirst();
if (isUpdating) {
@@ -162,7 +161,8 @@ export class Notes implements ICollection {
currentNoteTitleFields?.title !== headlineTitle
) {
item.title = titleFormat.replace(HEADLINE_REGEX, headlineTitle);
}
} else if (item.title === "")
item.title = currentNoteTitleFields?.title || "Untitled";
}
if (isUpdating) {