From d50a74327f87f162def11406586c8c049599f870 Mon Sep 17 00:00:00 2001 From: zeppi Date: Mon, 29 Nov 2021 22:26:12 -0500 Subject: [PATCH] improve sync --- ui/redux/actions/app.js | 3 +-- ui/redux/actions/sync.js | 13 ++++++++++--- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/ui/redux/actions/app.js b/ui/redux/actions/app.js index 3c8393fac..84da06b75 100644 --- a/ui/redux/actions/app.js +++ b/ui/redux/actions/app.js @@ -632,9 +632,8 @@ export function doGetAndPopulatePreferences() { export function doHandleSyncComplete(error, hasNewData) { return (dispatch) => { if (!error) { - dispatch(doGetAndPopulatePreferences()); - if (hasNewData) { + dispatch(doGetAndPopulatePreferences()); // we just got sync data, better update our channels dispatch(doFetchChannelListMine()); } diff --git a/ui/redux/actions/sync.js b/ui/redux/actions/sync.js index 8f05b1b0a..95a95b149 100644 --- a/ui/redux/actions/sync.js +++ b/ui/redux/actions/sync.js @@ -4,7 +4,12 @@ import * as SETTINGS from 'constants/settings'; import { Lbryio } from 'lbryinc'; import Lbry from 'lbry'; import { doWalletEncrypt, doWalletDecrypt } from 'redux/actions/wallet'; -import { selectGetSyncIsPending, selectSetSyncIsPending, selectSyncIsLocked } from 'redux/selectors/sync'; +import { + selectSyncHash, + selectGetSyncIsPending, + selectSetSyncIsPending, + selectSyncIsLocked, +} from 'redux/selectors/sync'; import { makeSelectClientSetting } from 'redux/selectors/settings'; import { getSavedPassword } from 'util/saved-passwords'; import { doAnalyticsTagSync, doHandleSyncComplete } from 'redux/actions/app'; @@ -154,7 +159,9 @@ export function doGetSync(passedPassword?: string, callback?: (any, ?boolean) => } } - return (dispatch: Dispatch) => { + return (dispatch: Dispatch, getState: GetState) => { + const state = getState(); + const localHash = selectSyncHash(state); dispatch({ type: ACTIONS.GET_SYNC_STARTED, }); @@ -182,7 +189,7 @@ export function doGetSync(passedPassword?: string, callback?: (any, ?boolean) => const syncHash = response.hash; data.syncHash = syncHash; data.syncData = response.data; - data.changed = response.changed; + data.changed = response.changed || syncHash !== localHash; data.hasSyncedWallet = true; if (response.changed) {