From c04d14c762aa2d84c330e3aad56a931f53758dcc Mon Sep 17 00:00:00 2001 From: Olaf Wintermann Date: Fri, 23 May 2025 19:54:29 +0200 Subject: [PATCH] only add new notes to the notes list when they have a title --- application/application.h | 1 + application/note.c | 13 ++++++++++--- application/notebook.c | 5 +++-- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/application/application.h b/application/application.h index 6fb9817..9104afb 100644 --- a/application/application.h +++ b/application/application.h @@ -157,6 +157,7 @@ struct NoteModel { UiInteger *textnote_code; bool modified; + bool new_note; }; typedef struct AttachmentModel { diff --git a/application/note.c b/application/note.c index 06ff6a3..86cdea8 100644 --- a/application/note.c +++ b/application/note.c @@ -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) { diff --git a/application/notebook.c b/application/notebook.c index 966a61c..7f361fb 100644 --- a/application/notebook.c +++ b/application/notebook.c @@ -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 { -- 2.43.5