From 1bb5ce72faac3e187b399718d0398fc689e34468 Mon Sep 17 00:00:00 2001 From: Akinwale Ariwodola Date: Wed, 22 Jul 2020 05:49:48 +0100 Subject: [PATCH] Proper fix for subscription sync retention. Eliminate double sync attempt on startup. --- .../java/io/lbry/browser/MainActivity.java | 12 ++++----- .../browser/tasks/MergeSubscriptionsTask.java | 26 +++++++++---------- .../browser/tasks/wallet/SyncGetTask.java | 2 +- 3 files changed, 20 insertions(+), 20 deletions(-) diff --git a/app/src/main/java/io/lbry/browser/MainActivity.java b/app/src/main/java/io/lbry/browser/MainActivity.java index cb523fce..cf33c4d2 100644 --- a/app/src/main/java/io/lbry/browser/MainActivity.java +++ b/app/src/main/java/io/lbry/browser/MainActivity.java @@ -306,7 +306,7 @@ public class MainActivity extends AppCompatActivity implements SdkStatusListener public static final String SECURE_VALUE_KEY_SAVED_PASSWORD = "io.lbry.browser.PX"; public static final String SECURE_VALUE_FIRST_RUN_PASSWORD = "firstRunPassword"; - private static final String TAG = "io.lbry.browser.Main"; + private static final String TAG = "LbryMain"; private NavigationMenuAdapter navMenuAdapter; private UrlSuggestionListAdapter urlSuggestionListAdapter; @@ -1567,7 +1567,6 @@ public class MainActivity extends AppCompatActivity implements SdkStatusListener findViewById(R.id.global_sdk_initializing_status).setVisibility(View.GONE); - syncWalletAndLoadPreferences(); scheduleWalletBalanceUpdate(); scheduleWalletSyncTask(); fetchOwnChannels(); @@ -1751,7 +1750,7 @@ public class MainActivity extends AppCompatActivity implements SdkStatusListener public void run() { syncWalletAndLoadPreferences(); } - }, 0, 5, TimeUnit.MINUTES); + }, 0, 2, TimeUnit.MINUTES); walletSyncScheduled = true; } } @@ -1785,7 +1784,7 @@ public class MainActivity extends AppCompatActivity implements SdkStatusListener //openNavFragments.get MergeSubscriptionsTask mergeTask = new MergeSubscriptionsTask( subscriptions, - !initialSubscriptionMergeDone(), + initialSubscriptionMergeDone(), MainActivity.this, new MergeSubscriptionsTask.MergeSubscriptionsHandler() { @Override public void onSuccess(List subscriptions, List diff) { @@ -1800,7 +1799,9 @@ public class MainActivity extends AppCompatActivity implements SdkStatusListener for (Fragment fragment : openNavFragments.values()) { if (fragment instanceof FollowingFragment) { // reload local subscriptions - ((FollowingFragment) fragment).fetchLoadedSubscriptions(true); + Lbryio.cacheResolvedSubscriptions.clear(); + FollowingFragment followingFragment = (FollowingFragment) fragment; + followingFragment.fetchLoadedSubscriptions(true); } } } @@ -1938,7 +1939,6 @@ public class MainActivity extends AppCompatActivity implements SdkStatusListener public void onSyncGetSuccess(WalletSync walletSync) { Lbryio.lastWalletSync = walletSync; Lbryio.lastRemoteHash = walletSync.getHash(); - loadSharedUserState(); } @Override diff --git a/app/src/main/java/io/lbry/browser/tasks/MergeSubscriptionsTask.java b/app/src/main/java/io/lbry/browser/tasks/MergeSubscriptionsTask.java index ff48f5d8..2d516e13 100644 --- a/app/src/main/java/io/lbry/browser/tasks/MergeSubscriptionsTask.java +++ b/app/src/main/java/io/lbry/browser/tasks/MergeSubscriptionsTask.java @@ -60,12 +60,12 @@ public class MergeSubscriptionsTask extends AsyncTask { if (applySyncChanges) { if (applySyncSuccessful) { handler.onSyncApplySuccess(syncHash, syncData); - } else { + } else if (syncApplyError != null) { handler.onSyncApplyError(syncApplyError); } }