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 { 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)),

View file

@ -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() {

View file

@ -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,
});
}
};
}