2020-11-13 19:09:28 +02:00
|
|
|
import { CommandContext, CommandDeclaration, CommandRuntime } from '@joplin/lib/services/CommandService';
|
2020-11-07 17:59:37 +02:00
|
|
|
import { _ } from '@joplin/lib/locale';
|
2020-11-13 19:09:28 +02:00
|
|
|
import setLayoutItemProps from '../../ResizableLayout/utils/setLayoutItemProps';
|
|
|
|
import layoutItemProp from '../../ResizableLayout/utils/layoutItemProp';
|
|
|
|
import { AppState } from '../../../app';
|
2020-07-03 23:32:39 +02:00
|
|
|
|
2020-11-12 21:13:28 +02:00
|
|
|
export const declaration: CommandDeclaration = {
|
2020-07-03 23:32:39 +02:00
|
|
|
name: 'toggleNoteList',
|
|
|
|
label: () => _('Toggle note list'),
|
2020-10-13 14:01:02 +02:00
|
|
|
iconName: 'fas fa-align-justify',
|
2020-07-03 23:32:39 +02:00
|
|
|
};
|
|
|
|
|
2020-11-13 19:09:28 +02:00
|
|
|
export const runtime = (): CommandRuntime => {
|
2020-07-03 23:32:39 +02:00
|
|
|
return {
|
2020-11-13 19:09:28 +02:00
|
|
|
execute: async (context: CommandContext) => {
|
|
|
|
const layout = (context.state as AppState).mainLayout;
|
|
|
|
|
|
|
|
const newLayout = setLayoutItemProps(layout, 'noteList', {
|
|
|
|
visible: !layoutItemProp(layout, 'noteList', 'visible'),
|
|
|
|
});
|
|
|
|
|
|
|
|
context.dispatch({
|
|
|
|
type: 'MAIN_LAYOUT_SET',
|
|
|
|
value: newLayout,
|
2020-07-03 23:32:39 +02:00
|
|
|
});
|
|
|
|
},
|
|
|
|
};
|
|
|
|
};
|