1
0
mirror of https://github.com/laurent22/joplin.git synced 2025-06-15 23:00:36 +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

@ -181,7 +181,7 @@ class BaseApplication {
process.exit(code);
}
async refreshNotes(state) {
async refreshNotes(state, useSelectedNoteId = false) {
let parentType = state.notesParentType;
let parentId = null;
@ -233,10 +233,17 @@ class BaseApplication {
notesSource: source,
});
this.store().dispatch({
type: 'NOTE_SELECT',
id: notes.length ? notes[0].id : null,
});
if (useSelectedNoteId) {
this.store().dispatch({
type: 'NOTE_SELECT',
id: state.selectedNoteIds && state.selectedNoteIds.length ? state.selectedNoteIds[0] : null,
});
} else {
this.store().dispatch({
type: 'NOTE_SELECT',
id: notes.length ? notes[0].id : null,
});
}
}
reducerActionToString(action) {
@ -273,13 +280,16 @@ class BaseApplication {
const result = next(action);
const newState = store.getState();
let refreshNotes = false;
let refreshNotesUseSelectedNoteId = false;
reduxSharedMiddleware(store, next, action);
if (action.type == 'FOLDER_SELECT' || action.type === 'FOLDER_DELETE' || (action.type === 'SEARCH_UPDATE' && newState.notesParentType === 'Folder')) {
if (action.type == 'FOLDER_SELECT' || action.type === 'FOLDER_DELETE' || action.type === 'FOLDER_AND_NOTE_SELECT' || (action.type === 'SEARCH_UPDATE' && newState.notesParentType === 'Folder')) {
Setting.setValue('activeFolderId', newState.selectedFolderId);
this.currentFolder_ = newState.selectedFolderId ? await Folder.load(newState.selectedFolderId) : null;
refreshNotes = true;
if (action.type === 'FOLDER_AND_NOTE_SELECT') refreshNotesUseSelectedNoteId = true;
}
if (this.hasGui() && ((action.type == 'SETTING_UPDATE_ONE' && action.key == 'uncompletedTodosOnTop') || action.type == 'SETTING_UPDATE_ALL')) {
@ -303,7 +313,7 @@ class BaseApplication {
}
if (refreshNotes) {
await this.refreshNotes(newState);
await this.refreshNotes(newState, refreshNotesUseSelectedNoteId);
}
if ((action.type == 'SETTING_UPDATE_ONE' && (action.key == 'dateFormat' || action.key == 'timeFormat')) || (action.type == 'SETTING_UPDATE_ALL')) {