1
0
mirror of https://github.com/laurent22/joplin.git synced 2025-11-26 22:41:17 +02:00

Fixed selection in note and folder list

This commit is contained in:
Laurent Cozic
2017-10-15 12:38:22 +01:00
parent 3d8327ae0b
commit 03facc93f5
3 changed files with 21 additions and 5 deletions

View File

@@ -158,12 +158,14 @@ const reducer = (state = defaultState, action) => {
const modNote = action.note;
let noteFolderHasChanged = false;
let newNotes = state.notes.slice();
var found = false;
for (let i = 0; i < newNotes.length; i++) {
let n = newNotes[i];
if (n.id == modNote.id) {
// Note is still in the same folder
if (!('parent_id' in modNote) || modNote.parent_id == n.parent_id) {
// Merge the properties that have changed (in modNote) into
// the object we already have.
@@ -174,8 +176,9 @@ const reducer = (state = defaultState, action) => {
newNotes[i][n] = modNote[n];
}
} else {
} else { // Note has moved to a different folder
newNotes.splice(i, 1);
noteFolderHasChanged = true;
}
found = true;
break;
@@ -187,6 +190,10 @@ const reducer = (state = defaultState, action) => {
newNotes = Note.sortNotes(newNotes, state.notesOrder, newState.settings.uncompletedTodosOnTop);
newState = Object.assign({}, state);
newState.notes = newNotes;
if (noteFolderHasChanged) {
newState.selectedNoteId = newNotes.length ? newNotes[0].id : null;
}
break;
case 'NOTES_DELETE':