Skip to content

A fully open source & end-to-end encrypted note taking alternative to Evernote.

core: set default title if note has no title

Abdullah Attac6bb28c139bc
diff --git a/packages/core/src/collections/notes.ts b/packages/core/src/collections/notes.ts
index 67b6989ec..2c36aa9ad 100644
--- a/packages/core/src/collections/notes.ts
+++ b/packages/core/src/collections/notes.ts
@@ -102,8 +102,16 @@ export class Notes implements ICollection {
}
if (item.title) {
- item.title = this.getNoteTitle(item.title, headline);
+ item.title = item.title.replace(NEWLINE_STRIP_REGEX, " ");
dateEdited = Date.now();
+ } else if (!isUpdating) {
+ 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) {
@@ -390,20 +398,6 @@ export class Notes implements ICollection {
}
});
}
-
- private getNoteTitle(title: string, headline?: string) {
- if (title.trim().length > 0) {
- return title.replace(NEWLINE_STRIP_REGEX, " ");
- }
-
- return formatTitle(
- this.db.settings.getTitleFormat(),
- this.db.settings.getDateFormat(),
- this.db.settings.getTimeFormat(),
- headline?.split(" ").splice(0, 10).join(" "),
- this.totalNotes
- );
- }
}
function getNoteHeadline(content: Tiptap) {