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

Fixed updating view when note is deleted

This commit is contained in:
Laurent Cozic
2017-10-09 20:57:00 +01:00
parent 30480a8029
commit 8c7cd8de88
7 changed files with 74 additions and 29 deletions

View File

@@ -191,15 +191,25 @@ const reducer = (state = defaultState, action) => {
case 'NOTES_DELETE':
var previousIndex = 0;
var newNotes = [];
for (let i = 0; i < state.notes.length; i++) {
let f = state.notes[i];
if (f.id == action.noteId) continue;
if (f.id == action.noteId) {
previousIndex = i;
continue;
}
newNotes.push(f);
}
newState = Object.assign({}, state);
newState.notes = newNotes;
if (previousIndex >= newNotes.length) {
previousIndex = newNotes.length - 1;
}
newState.selectedNoteId = previousIndex >= 0 ? newNotes[previousIndex].id : null;
break;
case 'FOLDERS_UPDATE_ALL':