]> uap-core.de Git - note.git/commitdiff
only add new notes to the notes list when they have a title
authorOlaf Wintermann <olaf.wintermann@gmail.com>
Fri, 23 May 2025 17:54:29 +0000 (19:54 +0200)
committerOlaf Wintermann <olaf.wintermann@gmail.com>
Fri, 23 May 2025 17:54:29 +0000 (19:54 +0200)
application/application.h
application/note.c
application/notebook.c

index 6fb9817c670dcc5566f5192bff74e939d2bed1b4..9104afb167b6df4e454f9acc868156683946ba8e 100644 (file)
@@ -157,6 +157,7 @@ struct NoteModel {
     UiInteger *textnote_code;
     
     bool modified;
+    bool new_note;
 };
 
 typedef struct AttachmentModel {
index 06ff6a3d437265c95b48e9ee47189f5465c2acfc..86cdea8be29ddb9c78aebd981e37cb46ab6ceef6 100644 (file)
@@ -256,18 +256,25 @@ void note_insert_list(NoteModel *note, UiBool ordered) {
 
 
 void note_update_title(NotebookModel *notebook, Note *note) {
+    NoteModel *m = note->model;
+    
     int index = notebookmode_get_note_index(notebook, note);
-    if(index < 0) {
+    if(index < 0 && !m->new_note) {
         return;
     }
-    NoteModel *m = note->model;
     m->modified = TRUE;
     
     char *title = ui_get(m->title);
     cxFree(m->note_allocator, note->resource->displayname);
     note->resource->displayname = cx_strdup_a(m->note_allocator, cx_str(title)).ptr;
     
-    notebook->notes->update(notebook->notes, index);
+    if(m->new_note) {
+        ui_list_append(notebook->notes, note);
+        ui_list_update(notebook->notes);
+        m->new_note = FALSE;
+    } else {
+        notebook->notes->update(notebook->notes, index);
+    }
 }
 
 const char* note_get_title(Resource *note) {
index 966a61c86e5e37359bf1cfa22a2141d781f7ec1f..7f361fbae752395016912a4c32c57faf55655efd 100644 (file)
@@ -208,12 +208,13 @@ void notebookmodel_new_note(NotebookModel *model) {
     new_resource->parent_id = model->collection->resource_id;
     notebookmodel_attach_note(model, new_note);
     new_note->model->modified = TRUE;
+    new_note->model->new_note = TRUE;
     // initialize note content
     // possible to implement something like note templates here
     editor_load_markdown(new_note, model->window->textview, cx_mutstrn("", 0));
     
-    ui_list_append(model->notes, new_note);
-    ui_list_update(model->notes);
+    //ui_list_append(model->notes, new_note);
+    //ui_list_update(model->notes);
 }
 
 typedef struct NoteDeleteOp {