You've already forked joplin
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:
@@ -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':
|
||||
|
||||
Reference in New Issue
Block a user