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) {
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 {