From b185857eb0a3424a5af0b08214881fc16074f3f4 Mon Sep 17 00:00:00 2001 From: jessop Date: Tue, 28 Jul 2020 22:52:44 -0400 Subject: [PATCH] trigger sync on theme change in nav menu --- ui/component/header/index.js | 3 ++- ui/component/header/view.jsx | 3 +++ ui/redux/actions/settings.js | 10 ++++++++-- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/ui/component/header/index.js b/ui/component/header/index.js index db551f2ff..53285e0f4 100644 --- a/ui/component/header/index.js +++ b/ui/component/header/index.js @@ -4,7 +4,7 @@ import { selectBalance, formatCredits, SETTINGS } from 'lbry-redux'; import { selectGetSyncErrorMessage } from 'lbryinc'; import { selectUserVerifiedEmail, selectUserEmail, selectEmailToVerify } from 'redux/selectors/user'; import { doClearEmailEntry, doClearPasswordEntry } from 'redux/actions/user'; -import { doSetClientSetting } from 'redux/actions/settings'; +import { doSetClientSetting, doSyncClientSettings } from 'redux/actions/settings'; import { doSignOut, doOpenModal } from 'redux/actions/app'; import { makeSelectClientSetting } from 'redux/selectors/settings'; import Header from './view'; @@ -26,6 +26,7 @@ const select = state => ({ const perform = dispatch => ({ setClientSetting: (key, value) => dispatch(doSetClientSetting(key, value)), + syncSettings: () => dispatch(doSyncClientSettings()), signOut: () => dispatch(doSignOut()), openMobileNavigation: () => dispatch(doOpenModal(MODALS.MOBILE_NAVIGATION)), openChannelCreate: () => dispatch(doOpenModal(MODALS.CREATE_CHANNEL)), diff --git a/ui/component/header/view.jsx b/ui/component/header/view.jsx index e4bc1737c..bdabe7b32 100644 --- a/ui/component/header/view.jsx +++ b/ui/component/header/view.jsx @@ -56,6 +56,7 @@ type Props = { clearEmailEntry: () => void, clearPasswordEntry: () => void, hasNavigated: boolean, + syncSettings: () => void, }; const Header = (props: Props) => { @@ -77,6 +78,7 @@ const Header = (props: Props) => { clearPasswordEntry, emailToVerify, backout, + syncSettings, } = props; const isMobile = useIsMobile(); // on the verify page don't let anyone escape other than by closing the tab to keep session data consistent @@ -149,6 +151,7 @@ const Header = (props: Props) => { } else { setClientSetting(SETTINGS.THEME, 'dark'); } + syncSettings(); } function getWalletTitle() { diff --git a/ui/redux/actions/settings.js b/ui/redux/actions/settings.js index af28d063e..9815439fe 100644 --- a/ui/redux/actions/settings.js +++ b/ui/redux/actions/settings.js @@ -168,8 +168,14 @@ export function doSetDarkTime(value, options) { } export function doSyncClientSettings() { - return { - type: LOCAL_ACTIONS.SYNC_CLIENT_SETTINGS, + return (dispatch, getState) => { + const state = getState(); + const syncEnabled = makeSelectClientSetting(SETTINGS.ENABLE_SYNC)(state); + if (syncEnabled) { + dispatch({ + type: LOCAL_ACTIONS.SYNC_CLIENT_SETTINGS, + }); + } }; }