2020-07-03 23:32:39 +02:00
|
|
|
import { CommandRuntime, CommandDeclaration } from '../lib/services/CommandService';
|
|
|
|
const { _ } = require('lib/locale');
|
|
|
|
const ExternalEditWatcher = require('lib/services/ExternalEditWatcher');
|
|
|
|
|
|
|
|
interface Props {
|
|
|
|
noteId: string
|
|
|
|
}
|
|
|
|
|
|
|
|
export const declaration:CommandDeclaration = {
|
|
|
|
name: 'stopExternalEditing',
|
|
|
|
label: () => _('Stop external editing'),
|
|
|
|
iconName: 'fa-stop',
|
|
|
|
};
|
|
|
|
|
|
|
|
export const runtime = ():CommandRuntime => {
|
|
|
|
return {
|
|
|
|
execute: async (props:Props) => {
|
|
|
|
ExternalEditWatcher.instance().stopWatching(props.noteId);
|
|
|
|
},
|
|
|
|
isEnabled: (props:any) => {
|
2020-09-21 18:09:57 +02:00
|
|
|
if (props.routeName !== 'Main') return false;
|
2020-07-03 23:32:39 +02:00
|
|
|
return !!props.noteId;
|
|
|
|
},
|
|
|
|
mapStateToProps: (state:any) => {
|
2020-09-21 18:09:57 +02:00
|
|
|
return { noteId: state.selectedNoteIds.length === 1 ? state.selectedNoteIds[0] : null, routeName: state.route.routeName };
|
2020-07-03 23:32:39 +02:00
|
|
|
},
|
|
|
|
};
|
|
|
|
};
|