Fix save & load settings

This commit is contained in:
Thomas Nordquist
2019-04-08 00:57:53 +02:00
parent 8c5f708386
commit a150da0254

View File

@@ -19,11 +19,11 @@ const settingsIdentifier: StorageIdentifier<Partial<SettingsState>> = {
id: 'Settings', id: 'Settings',
} }
export const loadSettings = () => async (dispatch: Dispatch<any>) => { export const loadSettings = () => async (dispatch: Dispatch<any>, getState: () => AppState) => {
try { try {
const settings = await persistentStorage.load(settingsIdentifier) const settings = await persistentStorage.load(settingsIdentifier) || {}
dispatch({ dispatch({
settings, settings: getState().settings.merge(settings),
type: ActionTypes.SETTINGS_DID_LOAD_SETTINGS, type: ActionTypes.SETTINGS_DID_LOAD_SETTINGS,
}) })
} catch (error) { } catch (error) {
@@ -34,7 +34,7 @@ export const loadSettings = () => async (dispatch: Dispatch<any>) => {
export const storeSettings = () => async (dispatch: Dispatch<any>, getState: () => AppState) => { export const storeSettings = () => async (dispatch: Dispatch<any>, getState: () => AppState) => {
const settings = { const settings = {
...getState().settings, ...getState().settings.toJS(),
topicFilter: undefined, topicFilter: undefined,
visible: undefined, visible: undefined,
} }