mirror of
https://github.com/laurent22/joplin.git
synced 2024-11-27 08:21:03 +02:00
Desktop: Resolves #6394: Improve performance when switching notes, when multiple plugins are loaded
By preventing the menu bar to needlessly re-render
This commit is contained in:
parent
39efc88059
commit
343b81ad09
@ -211,6 +211,12 @@ function useMenu(props: Props) {
|
||||
const [keymapLastChangeTime, setKeymapLastChangeTime] = useState(Date.now());
|
||||
const [modulesLastChangeTime, setModulesLastChangeTime] = useState(Date.now());
|
||||
|
||||
// We use a ref here because the plugin state can change frequently when
|
||||
// switching note since any plugin view might be rendered again. However we
|
||||
// need this plugin state only in a click handler when exporting notes, and
|
||||
// for that a ref is sufficient.
|
||||
const pluginsRef = useRef(props.plugins);
|
||||
|
||||
const onMenuItemClick = useCallback((commandName: string) => {
|
||||
void CommandService.instance().execute(commandName);
|
||||
}, []);
|
||||
@ -371,7 +377,7 @@ function useMenu(props: Props) {
|
||||
(action: any) => props.dispatch(action),
|
||||
module,
|
||||
{
|
||||
plugins: props.plugins,
|
||||
plugins: pluginsRef.current,
|
||||
customCss: props.customCss,
|
||||
}
|
||||
);
|
||||
@ -905,7 +911,6 @@ function useMenu(props: Props) {
|
||||
modulesLastChangeTime,
|
||||
props['spellChecker.language'],
|
||||
props['spellChecker.enabled'],
|
||||
props.plugins,
|
||||
props.customCss,
|
||||
props.locale,
|
||||
props.profileConfig,
|
||||
|
Loading…
Reference in New Issue
Block a user