Merge pull request #4602 from lbryio/fix-syncThemeSetting

trigger sync on theme change in nav menu
This commit is contained in:
jessopb 2020-07-29 17:56:06 -04:00 committed by GitHub
commit 2a5d87ee54
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
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) => {
type: LOCAL_ACTIONS.SYNC_CLIENT_SETTINGS, const state = getState();
const syncEnabled = makeSelectClientSetting(SETTINGS.ENABLE_SYNC)(state);
if (syncEnabled) {
dispatch({
type: LOCAL_ACTIONS.SYNC_CLIENT_SETTINGS,
});
}
}; };
} }