Skip to content

Commit

Permalink
Fix seafront group renaming local storage issue with redux persist mi…
Browse files Browse the repository at this point in the history
…gration
  • Loading branch information
ivangabriele committed May 29, 2024
1 parent 1d18e58 commit 9504c37
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
10 changes: 10 additions & 0 deletions frontend/src/store/migrations.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
export const MAIN_PERSISTOR_MISSION_MIGRATIONS = {
0: state => {
const nextState = {
...state,
listSeafrontGroup: state.listSeafrontGroup === 'ALL_SEAFRONT_GROUP' ? 'ALL' : state.listSeafrontGroup
}

return nextState
}
}
6 changes: 5 additions & 1 deletion frontend/src/store/reducers.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import { drawReducer } from '@features/Draw/slice'
import createMigrate from 'redux-persist/es/createMigrate'
import persistReducer from 'redux-persist/es/persistReducer'
import autoMergeLevel2 from 'redux-persist/es/stateReconciler/autoMergeLevel2'
import storage from 'redux-persist/es/storage' // LocalStorage

import { MAIN_PERSISTOR_MISSION_MIGRATIONS } from './migrations'
import { monitorenvApi, monitorfishApi, monitorfishLightApi, monitorfishPublicApi } from '../api/api'
import { beaconMalfunctionReducer } from '../domain/shared_slices/BeaconMalfunction'
import { controlReducer } from '../domain/shared_slices/Control'
Expand Down Expand Up @@ -91,7 +93,9 @@ export const mainReducer = {
...getCommonPersistReducerConfig<MissionListState>('mainPersistorMission', [
'listFilterValues',
'listSeafrontGroup'
])
]),
migrate: createMigrate(MAIN_PERSISTOR_MISSION_MIGRATIONS),
version: 0
},
missionListReducer
),
Expand Down

0 comments on commit 9504c37

Please sign in to comment.