diff --git a/ui/redux/actions/settings.js b/ui/redux/actions/settings.js index 6ee990bd3..f25886350 100644 --- a/ui/redux/actions/settings.js +++ b/ui/redux/actions/settings.js @@ -14,9 +14,10 @@ import { doAlertWaitingForSync, doGetAndPopulatePreferences } from 'redux/action import { selectPrefsReady } from 'redux/selectors/sync'; import { Lbryio } from 'lbryinc'; import { getDefaultLanguage } from 'util/default-languages'; +import { getSubsetFromKeysArray } from 'util/sync-settings'; const { DEFAULT_LANGUAGE } = require('config'); -const { SDK_SYNC_KEYS } = SHARED_PREFERENCES; +const { SDK_SYNC_KEYS, CLIENT_SYNC_KEYS } = SHARED_PREFERENCES; export const IS_MAC = process.platform === 'darwin'; const UPDATE_IS_NIGHT_INTERVAL = 5 * 60 * 1000; @@ -230,10 +231,17 @@ export function doSetWalletSyncPreference(pref) { } export function doPushSettingsToPrefs() { - return (dispatch) => { + return (dispatch, getState) => { + const state = getState(); + const { clientSettings } = state; + const sharedPreferences = Object.assign({}, state.sharedPreferences); + const selectedClientSettings = getSubsetFromKeysArray(clientSettings, CLIENT_SYNC_KEYS); + const newSharedPreferences = { ...sharedPreferences, ...selectedClientSettings }; + return new Promise((resolve, reject) => { dispatch({ type: ACTIONS.SYNC_CLIENT_SETTINGS, + data: newSharedPreferences, }); resolve(); }); diff --git a/ui/redux/reducers/settings.js b/ui/redux/reducers/settings.js index 7dcdf1c65..c52635966 100644 --- a/ui/redux/reducers/settings.js +++ b/ui/redux/reducers/settings.js @@ -162,12 +162,9 @@ reducers[ACTIONS.SHARED_PREFERENCE_SET] = (state, action) => { }); }; -reducers[ACTIONS.SYNC_CLIENT_SETTINGS] = (state) => { - const { clientSettings } = state; - const sharedPreferences = Object.assign({}, state.sharedPreferences); - const selectedClientSettings = getSubsetFromKeysArray(clientSettings, clientSyncKeys); - const newSharedPreferences = { ...sharedPreferences, ...selectedClientSettings }; - return Object.assign({}, state, { sharedPreferences: newSharedPreferences }); +reducers[ACTIONS.SYNC_CLIENT_SETTINGS] = (state, action) => { + const { data } = action; + return Object.assign({}, state, { sharedPreferences: data }); }; reducers[ACTIONS.USER_STATE_POPULATE] = (state, action) => {