1
0
mirror of https://github.com/laurent22/joplin.git synced 2024-12-24 10:27:10 +02:00

Mobile: Fixes #393: Fixed moving new notes before they are saved

This commit is contained in:
Laurent Cozic 2018-05-01 18:53:45 +01:00
parent 05faf55e8d
commit 398946d39a
2 changed files with 12 additions and 5 deletions

View File

@ -186,8 +186,8 @@ class NoteScreenComponent extends BaseScreenComponent {
shared.noteComponent_change(this, 'body', text); shared.noteComponent_change(this, 'body', text);
} }
async saveNoteButton_press() { async saveNoteButton_press(folderId = null) {
await shared.saveNoteButton_press(this); await shared.saveNoteButton_press(this, folderId);
Keyboard.dismiss(); Keyboard.dismiss();
} }
@ -560,7 +560,12 @@ class NoteScreenComponent extends BaseScreenComponent {
enabled: true, enabled: true,
selectedFolderId: folder ? folder.id : null, selectedFolderId: folder ? folder.id : null,
onValueChange: async (itemValue, itemIndex) => { onValueChange: async (itemValue, itemIndex) => {
if (note.id) await Note.moveToFolder(note.id, itemValue); if (!note.id) {
await this.saveNoteButton_press(itemValue);
} else {
await Note.moveToFolder(note.id, itemValue);
}
note.parent_id = itemValue; note.parent_id = itemValue;
const folder = await Folder.load(note.parent_id); const folder = await Folder.load(note.parent_id);

View File

@ -10,14 +10,16 @@ shared.noteExists = async function(noteId) {
return !!existingNote; return !!existingNote;
} }
shared.saveNoteButton_press = async function(comp) { shared.saveNoteButton_press = async function(comp, folderId = null) {
let note = Object.assign({}, comp.state.note); let note = Object.assign({}, comp.state.note);
// Note has been deleted while user was modifying it. In that case, we // Note has been deleted while user was modifying it. In that case, we
// just save a new note by clearing the note ID. // just save a new note by clearing the note ID.
if (note.id && !(await shared.noteExists(note.id))) delete note.id; if (note.id && !(await shared.noteExists(note.id))) delete note.id;
if (!note.parent_id) { if (folderId) {
note.parent_id = folderId;
} else if (!note.parent_id) {
let folder = await Folder.defaultFolder(); let folder = await Folder.defaultFolder();
if (!folder) return; if (!folder) return;
note.parent_id = folder.id; note.parent_id = folder.id;