Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(app-shell, app-shell-odd): Refactor app to use unsubscribe flags #14633

Closed
wants to merge 14 commits into from
Closed
Prev Previous commit
Next Next commit
remove the unsubscribe action
  • Loading branch information
mjhuff committed Mar 4, 2024
commit a689fcd497e8aaab6ae2918723602c2ca8ea0b4c
7 changes: 0 additions & 7 deletions app-shell-odd/src/notify.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,6 @@ export function registerNotify(
browserWindow: mainWindow,
hostname: '127.0.0.1',
})

case 'shell:NOTIFY_UNSUBSCRIBE':
return unsubscribe({
...action.payload,
browserWindow: mainWindow,
hostname: '127.0.0.1',
})
}
}
}
Expand Down
6 changes: 0 additions & 6 deletions app-shell/src/notify.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,6 @@ export function registerNotify(
...action.payload,
browserWindow: mainWindow,
})

case 'shell:NOTIFY_UNSUBSCRIBE':
return unsubscribe({
...action.payload,
browserWindow: mainWindow,
})
}
}
}
Expand Down
16 changes: 1 addition & 15 deletions app/src/redux/shell/__tests__/actions.test.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
import {
uiInitialized,
notifySubscribeAction,
notifyUnsubscribeAction,
} from '../actions'
import { uiInitialized, notifySubscribeAction } from '../actions'

import type { NotifyTopic } from '../types'

Expand All @@ -26,14 +22,4 @@ describe('shell actions', () => {
meta: { shell: true },
})
})
it('should be able to create an UNSUBSCRIBE action', () => {
expect(notifyUnsubscribeAction(MOCK_HOSTNAME, MOCK_TOPIC)).toEqual({
type: 'shell:NOTIFY_UNSUBSCRIBE',
payload: {
hostname: MOCK_HOSTNAME,
topic: MOCK_TOPIC,
},
meta: { shell: true },
})
})
})
15 changes: 0 additions & 15 deletions app/src/redux/shell/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import type {
RobotMassStorageDeviceEnumerated,
RobotMassStorageDeviceRemoved,
NotifySubscribeAction,
NotifyUnsubscribeAction,
NotifyTopic,
} from './types'

Expand All @@ -31,8 +30,6 @@ export const ROBOT_MASS_STORAGE_DEVICE_ENUMERATED: 'shell:ROBOT_MASS_STORAGE_DEV
'shell:ROBOT_MASS_STORAGE_DEVICE_ENUMERATED'
export const NOTIFY_SUBSCRIBE: 'shell:NOTIFY_SUBSCRIBE' =
'shell:NOTIFY_SUBSCRIBE'
export const NOTIFY_UNSUBSCRIBE: 'shell:NOTIFY_UNSUBSCRIBE' =
'shell:NOTIFY_UNSUBSCRIBE'

export const uiInitialized = (): UiInitializedAction => ({
type: UI_INITIALIZED,
Expand Down Expand Up @@ -124,15 +121,3 @@ export const notifySubscribeAction = (
},
meta: { shell: true },
})

export const notifyUnsubscribeAction = (
hostname: string,
topic: NotifyTopic
): NotifyUnsubscribeAction => ({
type: NOTIFY_UNSUBSCRIBE,
payload: {
hostname,
topic,
},
meta: { shell: true },
})
12 changes: 0 additions & 12 deletions app/src/redux/shell/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,6 @@ export type NotifyTopic =
| 'robot-server/runs'
| `robot-server/runs/${string}`

export type NotifyAction = 'subscribe' | 'unsubscribe'

export interface NotifySubscribeAction {
type: 'shell:NOTIFY_SUBSCRIBE'
payload: {
Expand All @@ -155,15 +153,6 @@ export interface NotifySubscribeAction {
meta: { shell: true }
}

export interface NotifyUnsubscribeAction {
type: 'shell:NOTIFY_UNSUBSCRIBE'
payload: {
hostname: string
topic: NotifyTopic
}
meta: { shell: true }
}

export type ShellAction =
| UiInitializedAction
| ShellUpdateAction
Expand All @@ -177,4 +166,3 @@ export type ShellAction =
| RobotMassStorageDeviceEnumerated
| RobotMassStorageDeviceRemoved
| NotifySubscribeAction
| NotifyUnsubscribeAction