From f3751e4ba670b25f4807a3348bf5a22769b8e303 Mon Sep 17 00:00:00 2001 From: Laurent Cozic Date: Thu, 7 Dec 2017 21:32:22 +0000 Subject: [PATCH] Mobile: Fixed auto-assignment of title for new notes --- .../lib/components/shared/note-screen-shared.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/ReactNativeClient/lib/components/shared/note-screen-shared.js b/ReactNativeClient/lib/components/shared/note-screen-shared.js index b7d5a6d83f..3e1328f4f2 100644 --- a/ReactNativeClient/lib/components/shared/note-screen-shared.js +++ b/ReactNativeClient/lib/components/shared/note-screen-shared.js @@ -29,9 +29,11 @@ shared.saveNoteButton_press = async function(comp) { } let isNew = !note.id; + let titleWasAutoAssigned = false; if (isNew && !note.title) { note.title = Note.defaultTitle(note); + titleWasAutoAssigned = true; } // Save only the properties that have changed @@ -54,8 +56,11 @@ shared.saveNoteButton_press = async function(comp) { // But we preserve the current title and body because // the user might have changed them between the time // saveNoteButton_press was called and the note was - // saved (it's done asynchronously) - note.title = stateNote.title; + // saved (it's done asynchronously). + // + // If the title was auto-assigned above, we don't restore + // it from the state because it will be empty there. + if (!titleWasAutoAssigned) note.title = stateNote.title; note.body = stateNote.body; }