1
0
mirror of https://github.com/laurent22/joplin.git synced 2025-08-13 22:12:50 +02:00

Desktop: Fixes #3219: Fix notebook associated with note when doing search, and expand correct notebook

This commit is contained in:
Laurent Cozic
2020-05-17 16:45:27 +01:00
parent c2684a8149
commit f8ad782991
2 changed files with 10 additions and 8 deletions

View File

@@ -6,6 +6,7 @@ const Setting = require('lib/models/Setting.js');
const { shim } = require('lib/shim.js'); const { shim } = require('lib/shim.js');
const MasterKey = require('lib/models/MasterKey'); const MasterKey = require('lib/models/MasterKey');
const Note = require('lib/models/Note'); const Note = require('lib/models/Note');
const Folder = require('lib/models/Folder');
const { MarkupToHtml } = require('lib/joplin-renderer'); const { MarkupToHtml } = require('lib/joplin-renderer');
const { _, setLocale } = require('lib/locale.js'); const { _, setLocale } = require('lib/locale.js');
const { Logger } = require('lib/logger.js'); const { Logger } = require('lib/logger.js');
@@ -306,6 +307,10 @@ class Application extends BaseApplication {
mustUpdateMenuItemStates = true; mustUpdateMenuItemStates = true;
} }
if (action.type === 'FOLDER_AND_NOTE_SELECT') {
await Folder.expandTree(newState.folders, action.folderId);
}
if (mustUpdateMenuItemStates) this.updateMenuItemStates(newState); if (mustUpdateMenuItemStates) this.updateMenuItemStates(newState);
return result; return result;

View File

@@ -15,7 +15,6 @@ interface ButtonClickEvent {
interface NoteToolbarProps { interface NoteToolbarProps {
theme: number, theme: number,
style: any, style: any,
selectedFolderId: string,
folders: any[], folders: any[],
watchedNoteFiles: string[], watchedNoteFiles: string[],
backwardHistoryNotes: any[], backwardHistoryNotes: any[],
@@ -38,12 +37,12 @@ function styles_(props:NoteToolbarProps) {
} }
function useToolbarItems(props:NoteToolbarProps) { function useToolbarItems(props:NoteToolbarProps) {
const { note, selectedFolderId, folders, watchedNoteFiles, notesParentType, dispatch const { note, folders, watchedNoteFiles, notesParentType, dispatch
, onButtonClick, backwardHistoryNotes, forwardHistoryNotes } = props; , onButtonClick, backwardHistoryNotes, forwardHistoryNotes } = props;
const toolbarItems = []; const toolbarItems = [];
const folder = Folder.byId(folders, selectedFolderId); const selectedNoteFolder = Folder.byId(folders, note.parent_id);
toolbarItems.push({ toolbarItems.push({
tooltip: _('Back'), tooltip: _('Back'),
@@ -69,17 +68,16 @@ function useToolbarItems(props:NoteToolbarProps) {
}, },
}); });
if (folder && ['Search', 'Tag', 'SmartFilter'].includes(notesParentType)) { if (selectedNoteFolder && ['Search', 'Tag', 'SmartFilter'].includes(notesParentType)) {
toolbarItems.push({ toolbarItems.push({
title: _('In: %s', substrWithEllipsis(folder.title, 0, 16)), title: _('In: %s', substrWithEllipsis(selectedNoteFolder.title, 0, 16)),
iconName: 'fa-book', iconName: 'fa-book',
onClick: () => { onClick: () => {
props.dispatch({ props.dispatch({
type: 'FOLDER_AND_NOTE_SELECT', type: 'FOLDER_AND_NOTE_SELECT',
folderId: folder.id, folderId: selectedNoteFolder.id,
noteId: note.id, noteId: note.id,
}); });
Folder.expandTree(folders, folder.parent_id);
}, },
}); });
} }
@@ -153,7 +151,6 @@ function NoteToolbar(props:NoteToolbarProps) {
const mapStateToProps = (state:any) => { const mapStateToProps = (state:any) => {
return { return {
selectedFolderId: state.selectedFolderId,
folders: state.folders, folders: state.folders,
watchedNoteFiles: state.watchedNoteFiles, watchedNoteFiles: state.watchedNoteFiles,
backwardHistoryNotes: state.backwardHistoryNotes, backwardHistoryNotes: state.backwardHistoryNotes,