trigger sync on theme change in nav menu

This commit is contained in:
jessop 2020-07-28 22:52:44 -04:00
parent ca38d2cbdc
commit b185857eb0
3 changed files with 13 additions and 3 deletions

View file

@ -4,7 +4,7 @@ import { selectBalance, formatCredits, SETTINGS } from 'lbry-redux';
import { selectGetSyncErrorMessage } from 'lbryinc'; import { selectGetSyncErrorMessage } from 'lbryinc';
import { selectUserVerifiedEmail, selectUserEmail, selectEmailToVerify } from 'redux/selectors/user'; import { selectUserVerifiedEmail, selectUserEmail, selectEmailToVerify } from 'redux/selectors/user';
import { doClearEmailEntry, doClearPasswordEntry } from 'redux/actions/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 { doSignOut, doOpenModal } from 'redux/actions/app';
import { makeSelectClientSetting } from 'redux/selectors/settings'; import { makeSelectClientSetting } from 'redux/selectors/settings';
import Header from './view'; import Header from './view';
@ -26,6 +26,7 @@ const select = state => ({
const perform = dispatch => ({ const perform = dispatch => ({
setClientSetting: (key, value) => dispatch(doSetClientSetting(key, value)), setClientSetting: (key, value) => dispatch(doSetClientSetting(key, value)),
syncSettings: () => dispatch(doSyncClientSettings()),
signOut: () => dispatch(doSignOut()), signOut: () => dispatch(doSignOut()),
openMobileNavigation: () => dispatch(doOpenModal(MODALS.MOBILE_NAVIGATION)), openMobileNavigation: () => dispatch(doOpenModal(MODALS.MOBILE_NAVIGATION)),
openChannelCreate: () => dispatch(doOpenModal(MODALS.CREATE_CHANNEL)), openChannelCreate: () => dispatch(doOpenModal(MODALS.CREATE_CHANNEL)),

View file

@ -56,6 +56,7 @@ type Props = {
clearEmailEntry: () => void, clearEmailEntry: () => void,
clearPasswordEntry: () => void, clearPasswordEntry: () => void,
hasNavigated: boolean, hasNavigated: boolean,
syncSettings: () => void,
}; };
const Header = (props: Props) => { const Header = (props: Props) => {
@ -77,6 +78,7 @@ const Header = (props: Props) => {
clearPasswordEntry, clearPasswordEntry,
emailToVerify, emailToVerify,
backout, backout,
syncSettings,
} = props; } = props;
const isMobile = useIsMobile(); const isMobile = useIsMobile();
// on the verify page don't let anyone escape other than by closing the tab to keep session data consistent // 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 { } else {
setClientSetting(SETTINGS.THEME, 'dark'); setClientSetting(SETTINGS.THEME, 'dark');
} }
syncSettings();
} }
function getWalletTitle() { function getWalletTitle() {

View file

@ -168,8 +168,14 @@ export function doSetDarkTime(value, options) {
} }
export function doSyncClientSettings() { export function doSyncClientSettings() {
return { return (dispatch, getState) => {
const state = getState();
const syncEnabled = makeSelectClientSetting(SETTINGS.ENABLE_SYNC)(state);
if (syncEnabled) {
dispatch({
type: LOCAL_ACTIONS.SYNC_CLIENT_SETTINGS, type: LOCAL_ACTIONS.SYNC_CLIENT_SETTINGS,
});
}
}; };
} }