diff --git a/src/features/hotkeys/AppHotkeys.jsx b/src/features/hotkeys/AppHotkeys.jsx index eff111433..3d2385f98 100644 --- a/src/features/hotkeys/AppHotkeys.jsx +++ b/src/features/hotkeys/AppHotkeys.jsx @@ -23,6 +23,7 @@ import { openUAVDetailsDialog } from '~/features/uavs/details'; import { getSelectedUAVIds, getUAVIdList } from '~/features/uavs/selectors'; import { clearStoreAfterConfirmation } from '~/store'; import { createUAVOperationThunks } from '~/utils/messaging'; +import { submitPromptDialog } from '~/features/prompt/actions'; import { appendToPendingUAVId, @@ -116,7 +117,10 @@ export default connect( { ACTIVATE_SELECTION: handlePendingUAVIdThenDispatch( () => (dispatch, getState) => { - if (isKeyboardNavigationActive()) { + const state = getState(); + if (state.dialogs.prompt.open) { + dispatch(submitPromptDialog({ confirmed: true })); + } else if (isKeyboardNavigationActive()) { sendKeyboardNavigationSignal('ACTIVATE_SELECTION')(); } else { const selectedUAVIds = getSelectedUAVIds(getState()); diff --git a/src/utils/messaging.js b/src/utils/messaging.js index f0b79d86b..c8fa4b1b7 100644 --- a/src/utils/messaging.js +++ b/src/utils/messaging.js @@ -17,6 +17,7 @@ import messageHub from '~/message-hub'; import store from '~/store'; import makeLogger from './logging'; +import { getUAVById } from '~/features/uavs/selectors'; const logger = makeLogger('messaging'); @@ -199,23 +200,6 @@ export const wakeUpUAVs = performMassOperation({ name: 'Resume from low-power mode command', }); -const moveUAVsLowLevel = performMassOperation({ - type: 'UAV-FLY', - name: 'Fly to target command', - mapper: ({ target }) => ({ - target: [ - Math.round(target.lat * 1e7), - Math.round(target.lon * 1e7), - isNil(target.amsl) ? null : Math.round(target.amsl * 1e3), - isNil(target.ahl) ? null : Math.round(target.ahl * 1e3), - isNil(target.agl) ? null : Math.round(target.agl * 1e3), - ], - }), - - // Moving UAVs is such a common feature that we skip any confirmation dialogs - skipConfirmation: true, -}); - export const moveUAVs = (uavIds, { target, ...rest }) => { if (isNil(target)) { throw new Error('No target given in arguments'); @@ -239,7 +223,26 @@ export const moveUAVs = (uavIds, { target, ...rest }) => { args.target = { lat, lon }; } - return moveUAVsLowLevel(uavIds, args); + // Only skip confirmation if all UAVs are already in guided mode (normally due to a previous move command) + const skipConfirmation = uavIds + .map((id) => getUAVById(store.getState(), id)) + .every((uav) => uav.mode === 'guided'); + + return performMassOperation({ + type: 'UAV-FLY', + name: 'Fly to target command', + mapper: ({ target }) => ({ + target: [ + Math.round(target.lat * 1e7), + Math.round(target.lon * 1e7), + isNil(target.amsl) ? null : Math.round(target.amsl * 1e3), + isNil(target.ahl) ? null : Math.round(target.ahl * 1e3), + isNil(target.agl) ? null : Math.round(target.agl * 1e3), + ], + }), + + skipConfirmation, + })(uavIds, args); }; export const turnMotorsOffForUAVs = performMassOperation({