1
0
mirror of https://github.com/laurent22/joplin.git synced 2025-06-12 22:57:38 +02:00

Desktop: Fixes #953 (maybe): Improved the way internal links to notes are loaded to make it more reliable

This commit is contained in:
Laurent Cozic
2018-11-08 00:58:06 +00:00
parent 5c1dd79435
commit 28b1d8a324
3 changed files with 46 additions and 24 deletions

View File

@ -169,8 +169,25 @@ function defaultNotesParentType(state, exclusion) {
return newNotesParentType;
}
function changeSelectedFolder(state, action) {
newState = Object.assign({}, state);
newState.selectedFolderId = 'folderId' in action ? action.folderId : action.id;
if (!newState.selectedFolderId) {
newState.notesParentType = defaultNotesParentType(state, 'Folder');
} else {
newState.notesParentType = 'Folder';
}
return newState;
}
function changeSelectedNotes(state, action) {
const noteIds = 'id' in action ? (action.id ? [action.id] : []) : action.ids;
let noteIds = [];
if (action.id) noteIds = [action.id];
if (action.ids) noteIds = action.ids;
if (action.noteId) noteIds = [action.noteId];
// const noteIds = 'id' in action ? (action.id ? [action.id] : []) : action.ids;
let newState = Object.assign({}, state);
if (action.type === 'NOTE_SELECT') {
@ -279,13 +296,14 @@ const reducer = (state = defaultState, action) => {
case 'FOLDER_SELECT':
newState = Object.assign({}, state);
newState.selectedFolderId = action.id;
if (!action.id) {
newState.notesParentType = defaultNotesParentType(state, 'Folder');
} else {
newState.notesParentType = 'Folder';
}
newState = changeSelectedFolder(state, action);
break;
case 'FOLDER_AND_NOTE_SELECT':
newState = changeSelectedFolder(state, action);
const noteSelectAction = Object.assign({}, action, { type: 'NOTE_SELECT'});
newState = changeSelectedNotes(newState, noteSelectAction);
break;
case 'SETTING_UPDATE_ALL':