Merge pull request #4615 from lbryio/fix-pullSyncOnSettings

pull sync on nav to settings
This commit is contained in:
jessopb 2020-07-31 17:17:44 -04:00 committed by GitHub
commit e4b5140361
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 3 deletions

View file

@ -3,7 +3,7 @@ import { selectUserVerifiedEmail } from 'redux/selectors/user';
import { selectHasNavigated, selectScrollStartingPosition, selectWelcomeVersion } from 'redux/selectors/app'; import { selectHasNavigated, selectScrollStartingPosition, selectWelcomeVersion } from 'redux/selectors/app';
import Router from './view'; import Router from './view';
import { normalizeURI, makeSelectTitleForUri } from 'lbry-redux'; import { normalizeURI, makeSelectTitleForUri } from 'lbry-redux';
import { doSetHasNavigated } from 'redux/actions/app'; import { doSetHasNavigated, doSyncWithPreferences } from 'redux/actions/app';
import { doSyncClientSettings } from 'redux/actions/settings'; import { doSyncClientSettings } from 'redux/actions/settings';
const select = state => { const select = state => {
const { pathname, hash } = state.router.location; const { pathname, hash } = state.router.location;
@ -35,6 +35,7 @@ const select = state => {
const perform = dispatch => ({ const perform = dispatch => ({
setHasNavigated: () => dispatch(doSetHasNavigated()), setHasNavigated: () => dispatch(doSetHasNavigated()),
syncSettings: () => dispatch(doSyncClientSettings()), syncSettings: () => dispatch(doSyncClientSettings()),
checkSync: () => dispatch(doSyncWithPreferences()),
}); });
export default connect(select, perform)(Router); export default connect(select, perform)(Router);

View file

@ -98,6 +98,7 @@ type Props = {
hasNavigated: boolean, hasNavigated: boolean,
setHasNavigated: () => void, setHasNavigated: () => void,
syncSettings: () => void, syncSettings: () => void,
checkSync: () => void,
}; };
function AppRouter(props: Props) { function AppRouter(props: Props) {
@ -112,6 +113,7 @@ function AppRouter(props: Props) {
hasNavigated, hasNavigated,
setHasNavigated, setHasNavigated,
syncSettings, syncSettings,
checkSync,
} = props; } = props;
const { entries } = history; const { entries } = history;
const entryIndex = history.index; const entryIndex = history.index;
@ -135,11 +137,11 @@ function AppRouter(props: Props) {
if (!location.pathname.includes(PAGES.SETTINGS) && prevPath.includes(PAGES.SETTINGS)) { if (!location.pathname.includes(PAGES.SETTINGS) && prevPath.includes(PAGES.SETTINGS)) {
syncSettings(); syncSettings();
} else if (location.pathname.includes(PAGES.SETTINGS) && !prevPath.includes(PAGES.SETTINGS)) { } else if (location.pathname.includes(PAGES.SETTINGS) && !prevPath.includes(PAGES.SETTINGS)) {
syncSettings(); checkSync();
} }
}); });
return unlisten; return unlisten;
}, [prevPath, syncSettings]); }, [prevPath, syncSettings, checkSync]);
useEffect(() => { useEffect(() => {
const unlisten = history.listen(location => { const unlisten = history.listen(location => {