Skip to content

Commit

Permalink
fix(ardrive-web):In sync, check if profile is arconnect only if logge…
Browse files Browse the repository at this point in the history
…d in PE-112 (#184)

* fix(ardrive-web):check arconnect only if logged in
PE-112

* task(ardrive-web): elaborate comments PE-112
  • Loading branch information
javdhu authored Aug 3, 2021
1 parent 1a1fdaf commit 59ea432
Showing 1 changed file with 15 additions and 13 deletions.
28 changes: 15 additions & 13 deletions lib/blocs/sync/sync_cubit.dart
Original file line number Diff line number Diff line change
Expand Up @@ -63,23 +63,25 @@ class SyncCubit extends Cubit<SyncState> {

Future<void> 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.
//
Expand Down

0 comments on commit 59ea432

Please sign in to comment.