-
Notifications
You must be signed in to change notification settings - Fork 66
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add migration to remove appUiConfigs key
- Loading branch information
Showing
7 changed files
with
73 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { PersistedState } from 'redux-persist'; | ||
|
||
import { PersistAppStateV3, V3AppUiConfigs } from './3'; | ||
|
||
export type V4AppUiConfigs = Omit<V3AppUiConfigs, 'shouldHideLaunchableMarkets'>; | ||
|
||
export type PersistAppStateV4 = PersistedState & { | ||
appUiConfigs: V4AppUiConfigs; | ||
}; | ||
|
||
/** | ||
* Deprecate shouldHideLaunchableMarkets from AppUIConfigs state | ||
* | ||
*/ | ||
export function migration4(state: PersistAppStateV3 | undefined): PersistAppStateV4 { | ||
if (!state) throw new Error('state must be defined'); | ||
|
||
const appUiConfigsCopy = { ...state.appUiConfigs }; | ||
|
||
// Remove shouldHideLaunchableMarkets | ||
// eslint-disable-next-line @typescript-eslint/no-unused-vars | ||
const { shouldHideLaunchableMarkets, ...restAppUiConfigs } = appUiConfigsCopy; | ||
|
||
return { | ||
...state, | ||
appUiConfigs: restAppUiConfigs, | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import { afterEach, describe, expect, it } from 'vitest'; | ||
|
||
import { PersistAppStateV3, V3AppColorMode, V3AppTheme, V3DisplayUnit } from '../3'; | ||
import { migration4, PersistAppStateV4 } from '../4'; | ||
|
||
const v3State: PersistAppStateV3 = { | ||
_persist: { version: 3, rehydrated: true }, | ||
appUiConfigs: { | ||
appThemeSetting: V3AppTheme.Classic, | ||
appColorMode: V3AppColorMode.GreenUp, | ||
hasSeenLaunchIncentives: false, | ||
defaultToAllMarketsInPositionsOrdersFills: true, | ||
displayUnit: V3DisplayUnit.Asset, | ||
shouldHideLaunchableMarkets: false, | ||
}, | ||
}; | ||
|
||
const v4State: PersistAppStateV4 = { | ||
_persist: { version: 4, rehydrated: true }, | ||
appUiConfigs: { | ||
appThemeSetting: V3AppTheme.Classic, | ||
appColorMode: V3AppColorMode.GreenUp, | ||
hasSeenLaunchIncentives: false, | ||
defaultToAllMarketsInPositionsOrdersFills: true, | ||
displayUnit: V3DisplayUnit.Asset, | ||
}, | ||
}; | ||
|
||
describe('migration4', () => { | ||
afterEach(() => { | ||
localStorage.clear(); | ||
}); | ||
|
||
it('updated appUiConfigs state should not include shouldHideLaunchableMarkets', () => { | ||
const result = migration4(v3State); | ||
expect(result.appUiConfigs).toMatchObject(v4State.appUiConfigs); | ||
}); | ||
}); |