Desktop: Fixes #3748: Fixed issue when switching from search to "All notes"

pull/3787/head
Laurent Cozic 2020-09-21 17:50:59 +01:00
parent 27c572b2f5
commit f652011d59
2 changed files with 16 additions and 12 deletions

View File

@ -1,7 +1,5 @@
import { CommandRuntime, CommandDeclaration } from '../../../lib/services/CommandService'; import { CommandRuntime, CommandDeclaration } from '../../../lib/services/CommandService';
const Note = require('lib/models/Note');
const BaseModel = require('lib/BaseModel'); const BaseModel = require('lib/BaseModel');
// const { _ } = require('lib/locale');
const { uuid } = require('lib/uuid.js'); const { uuid } = require('lib/uuid.js');
export const declaration:CommandDeclaration = { export const declaration:CommandDeclaration = {
@ -31,14 +29,18 @@ export const runtime = (comp:any):CommandRuntime => {
id: comp.searchId_, id: comp.searchId_,
}); });
} else { } else {
const note = await Note.load(comp.props.selectedNoteId); // Note: Normally there's no need to do anything when the search query
if (note) { // is cleared as the reducer should handle all state changes.
comp.props.dispatch({ // https://github.com/laurent22/joplin/issues/3748
type: 'FOLDER_AND_NOTE_SELECT',
folderId: note.parent_id, // const note = await Note.load(comp.props.selectedNoteId);
noteId: note.id, // if (note) {
}); // comp.props.dispatch({
} // type: 'FOLDER_AND_NOTE_SELECT',
// folderId: note.parent_id,
// noteId: note.id,
// });
// }
} }
}, },
}; };

View File

@ -313,7 +313,9 @@ function updateSelectedNotesFromExistingNotes(state) {
function defaultNotesParentType(state, exclusion) { function defaultNotesParentType(state, exclusion) {
let newNotesParentType = null; let newNotesParentType = null;
if (exclusion !== 'Folder' && state.selectedFolderId) { if (exclusion !== 'SmartFilter' && state.selectedSmartFilterId) {
newNotesParentType = 'SmartFilter';
} else if (exclusion !== 'Folder' && state.selectedFolderId) {
newNotesParentType = 'Folder'; newNotesParentType = 'Folder';
} else if (exclusion !== 'Tag' && state.selectedTagId) { } else if (exclusion !== 'Tag' && state.selectedTagId) {
newNotesParentType = 'Tag'; newNotesParentType = 'Tag';
@ -543,7 +545,7 @@ function handleHistory(state, action) {
} }
const reducer = (state = defaultState, action) => { const reducer = (state = defaultState, action) => {
// if (!['SIDE_MENU_OPEN_PERCENT'].includes(action.type)) console.info('Action', action.type); // if (!['SIDE_MENU_OPEN_PERCENT'].includes(action.type)) console.info('Action', action.type, action);
let newState = state; let newState = state;