Navigation Menu

Skip to content
This repository has been archived by the owner on Apr 17, 2023. It is now read-only.

Commit

Permalink
Bump redux state version and only preserve API settings that should n…
Browse files Browse the repository at this point in the history
…ot change on update instead of everything.
  • Loading branch information
yknl committed Dec 20, 2018
1 parent 5f7fa28 commit 709cb48
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions app/js/store/reducers.js
Expand Up @@ -8,6 +8,7 @@ import { SanityReducer } from './sanity'
import SettingsReducer from '../account/store/settings/reducer'
import { AppsReducer } from './apps'
import { DELETE_ACCOUNT } from '../account/store/account/types'
import DEFAULT_API from '../account/store/settings/default'

export const UPDATE_STATE = 'UPDATE_STATE'
export const MIGRATE_API_ENDPOINTS = 'MIGRATE_API_ENDPOINTS'
Expand Down Expand Up @@ -38,7 +39,7 @@ export function initializeStateVersion() {
* and other state is regenerated.
* @type {number}
*/
export const CURRENT_VERSION: number = 14
export const CURRENT_VERSION: number = 15

const AppReducer = combineReducers({
account: AccountReducer,
Expand All @@ -54,9 +55,18 @@ function reducer(state: any, action: any) {
let newState: any = Object.assign({}, state)
if (action.type === UPDATE_STATE) {
const initialState = AppReducer(undefined, {})

const preservedApiSettingsState = {
gaiaHubUrl: state.settings.api.gaiaHubUrl,
distinctEventId: state.settings.api.distinctEventId,
hasDisabledEventTracking: state.settings.api.hasDisabledEventTracking
}

const newApiSettingsState = Object.assign(DEFAULT_API, preservedApiSettingsState)

newState = Object.assign({}, initialState, {
settings: {
api: Object.assign({}, state.settings.api)
api: newApiSettingsState
},
account: Object.assign({}, initialState.account, {
promptedForEmail: state.account.promptedForEmail,
Expand Down

0 comments on commit 709cb48

Please sign in to comment.