pull sync on nav to settings
This commit is contained in:
parent
c65afb201d
commit
314fb22638
2 changed files with 6 additions and 3 deletions
|
@ -3,7 +3,7 @@ import { selectUserVerifiedEmail } from 'redux/selectors/user';
|
|||
import { selectHasNavigated, selectScrollStartingPosition, selectWelcomeVersion } from 'redux/selectors/app';
|
||||
import Router from './view';
|
||||
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';
|
||||
const select = state => {
|
||||
const { pathname, hash } = state.router.location;
|
||||
|
@ -35,6 +35,7 @@ const select = state => {
|
|||
const perform = dispatch => ({
|
||||
setHasNavigated: () => dispatch(doSetHasNavigated()),
|
||||
syncSettings: () => dispatch(doSyncClientSettings()),
|
||||
checkSync: () => dispatch(doSyncWithPreferences()),
|
||||
});
|
||||
|
||||
export default connect(select, perform)(Router);
|
||||
|
|
|
@ -98,6 +98,7 @@ type Props = {
|
|||
hasNavigated: boolean,
|
||||
setHasNavigated: () => void,
|
||||
syncSettings: () => void,
|
||||
checkSync: () => void,
|
||||
};
|
||||
|
||||
function AppRouter(props: Props) {
|
||||
|
@ -112,6 +113,7 @@ function AppRouter(props: Props) {
|
|||
hasNavigated,
|
||||
setHasNavigated,
|
||||
syncSettings,
|
||||
checkSync,
|
||||
} = props;
|
||||
const { entries } = history;
|
||||
const entryIndex = history.index;
|
||||
|
@ -135,11 +137,11 @@ function AppRouter(props: Props) {
|
|||
if (!location.pathname.includes(PAGES.SETTINGS) && prevPath.includes(PAGES.SETTINGS)) {
|
||||
syncSettings();
|
||||
} else if (location.pathname.includes(PAGES.SETTINGS) && !prevPath.includes(PAGES.SETTINGS)) {
|
||||
syncSettings();
|
||||
checkSync();
|
||||
}
|
||||
});
|
||||
return unlisten;
|
||||
}, [prevPath, syncSettings]);
|
||||
}, [prevPath, syncSettings, checkSync]);
|
||||
|
||||
useEffect(() => {
|
||||
const unlisten = history.listen(location => {
|
||||
|
|
Loading…
Reference in a new issue