Skip to content

Commit

Permalink
Add cockpit-action to change to previous view
Browse files Browse the repository at this point in the history
  • Loading branch information
rafaellehmkuhl committed Jul 31, 2023
1 parent e6a5856 commit 7b2ba70
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/libs/joystick/protocols.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ export class MavlinkControllerState extends ProtocolControllerState {
*/
export enum CockpitAction {
GO_TO_NEXT_VIEW = 'Go to next view',
GO_TO_PREVIOUS_VIEW = 'Go to previous view',
TOGGLE_FULL_SCREEN = 'Toggle full-screen',
MAVLINK_ARM = 'Mavlink Command - Arm',
MAVLINK_DISARM = 'Mavlink Command - Disarm',
Expand Down
7 changes: 7 additions & 0 deletions src/stores/widgetManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,13 @@ export const useWidgetManagerStore = defineStore('widget-manager', () => {
const selectNextViewCallbackId = registerActionCallback(CockpitAction.GO_TO_NEXT_VIEW, debouncedSelectNextView)
onBeforeUnmount(() => unregisterActionCallback(selectNextViewCallbackId))

const selectPreviousView = (): void => {
const indexOfCurrentView = currentProfile.value.views.indexOf(currentView.value)
selectView(currentProfile.value.views[indexOfCurrentView - 1])
}
const debouncedSelectPreviousView = useDebounceFn(() => selectPreviousView(), 500)
const selectPrevViewCBId = registerActionCallback(CockpitAction.GO_TO_PREVIOUS_VIEW, debouncedSelectPreviousView)
onBeforeUnmount(() => unregisterActionCallback(selectPrevViewCBId))

return {
editingMode,
Expand Down

0 comments on commit 7b2ba70

Please sign in to comment.