diff --git a/desktop/app/src/reducers/connections.tsx b/desktop/app/src/reducers/connections.tsx index ce46256ee..0c8b609c8 100644 --- a/desktop/app/src/reducers/connections.tsx +++ b/desktop/app/src/reducers/connections.tsx @@ -31,22 +31,35 @@ export type StaticView = | ComponentType | React.FunctionComponent; -export type State = StateV1; +export type State = StateV2; -export const persistVersion = 1; +export const persistVersion = 2; export const persistMigrations = { 1: (state: any) => { const stateV0 = state as StateV0; const stateV1 = { ...stateV0, - enabledPlugins: stateV0.userStarredPlugins, - enabledDevicePlugins: stateV0.userStarredDevicePlugins, + enabledPlugins: stateV0.userStarredPlugins ?? {}, + enabledDevicePlugins: + stateV0.userStarredDevicePlugins ?? + new Set(INITAL_STATE.enabledDevicePlugins), }; return stateV1 as any; }, + 2: (state: any) => { + const stateV1 = state as StateV1; + const stateV2 = { + ...stateV1, + enabledPlugins: stateV1.enabledPlugins ?? {}, + enabledDevicePlugins: + stateV1.enabledDevicePlugins ?? + new Set(INITAL_STATE.enabledDevicePlugins), + }; + return stateV2 as any; + }, }; -type StateV1 = { +type StateV2 = { devices: Array; androidEmulators: Array; selectedDevice: null | BaseDevice; @@ -67,9 +80,14 @@ type StateV1 = { staticView: StaticView; }; +type StateV1 = Omit & { + enabledPlugins?: {[client: string]: string[]}; + enabledDevicePlugins?: Set; +}; + type StateV0 = Omit & { - userStarredPlugins: {[client: string]: string[]}; - userStarredDevicePlugins: Set; + userStarredPlugins?: {[client: string]: string[]}; + userStarredDevicePlugins?: Set; }; export type Action =