From 59ea432ef4d9f92c4ec6a943901f7c73bd0a2dec Mon Sep 17 00:00:00 2001 From: Javed Hussein Date: Tue, 3 Aug 2021 16:22:55 -0400 Subject: [PATCH] fix(ardrive-web):In sync, check if profile is arconnect only if logged in PE-112 (#184) * fix(ardrive-web):check arconnect only if logged in PE-112 * task(ardrive-web): elaborate comments PE-112 --- lib/blocs/sync/sync_cubit.dart | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/lib/blocs/sync/sync_cubit.dart b/lib/blocs/sync/sync_cubit.dart index 4336340c58..c42ed32934 100644 --- a/lib/blocs/sync/sync_cubit.dart +++ b/lib/blocs/sync/sync_cubit.dart @@ -63,23 +63,25 @@ class SyncCubit extends Cubit { Future startSync() async { try { - final isArConnect = await _profileCubit.isCurrentProfileArConnect(); - - if (isArConnect && window.document.visibilityState != 'visible') { - print('Tab hidden, skipping sync...'); - emit(SyncIdle()); - return; - } + final profile = _profileCubit.state; print('Syncing...'); - if (await _profileCubit.logoutIfWalletMismatch()) { - emit(SyncWalletMismatch()); - return; - } emit(SyncInProgress()); - final profile = _profileCubit.state; - // Only sync in drives owned by the user if they're logged in. if (profile is ProfileLoggedIn) { + + //Check if profile is ArConnect to skip sync while tab is hidden + final isArConnect = await _profileCubit.isCurrentProfileArConnect(); + + if (isArConnect && window.document.visibilityState != 'visible') { + print('Tab hidden, skipping sync...'); + emit(SyncIdle()); + return; + } + + if (await _profileCubit.logoutIfWalletMismatch()) { + emit(SyncWalletMismatch()); + return; + } // This syncs in the latest info on drives owned by the user and will be overwritten // below when the full sync process is ran. //