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. //