1
0
mirror of https://github.com/laurent22/joplin.git synced 2025-02-13 19:42:36 +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 MasterKey = require('lib/models/MasterKey');
const Note = require('lib/models/Note');
const Folder = require('lib/models/Folder');
const { MarkupToHtml } = require('lib/joplin-renderer');
const { _, setLocale } = require('lib/locale.js');
const { Logger } = require('lib/logger.js');
@ -306,6 +307,10 @@ class Application extends BaseApplication {
mustUpdateMenuItemStates = true;
}
if (action.type === 'FOLDER_AND_NOTE_SELECT') {
await Folder.expandTree(newState.folders, action.folderId);
}
if (mustUpdateMenuItemStates) this.updateMenuItemStates(newState);
return result;

View File

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