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