@ -12,6 +12,7 @@ import 'package:immich_mobile/presentation/widgets/backup/backup_toggle_button.w
import ' package:immich_mobile/providers/background_sync.provider.dart ' ;
import ' package:immich_mobile/providers/backup/backup_album.provider.dart ' ;
import ' package:immich_mobile/providers/backup/drift_backup.provider.dart ' ;
import ' package:immich_mobile/providers/sync_status.provider.dart ' ;
import ' package:immich_mobile/providers/user.provider.dart ' ;
import ' package:immich_mobile/routing/router.dart ' ;
import ' package:immich_mobile/widgets/backup/backup_info_card.dart ' ;
@ -33,7 +34,14 @@ class _DriftBackupPageState extends ConsumerState<DriftBackupPage> {
return ;
}
ref . read ( driftBackupProvider . notifier ) . getBackupStatus ( currentUser . id ) ;
WidgetsBinding . instance . addPostFrameCallback ( ( _ ) async {
await ref . read ( driftBackupProvider . notifier ) . getBackupStatus ( currentUser . id ) ;
await ref . read ( backgroundSyncProvider ) . syncRemote ( ) ;
if ( mounted ) {
await ref . read ( driftBackupProvider . notifier ) . getBackupStatus ( currentUser . id ) ;
}
} ) ;
}
@ override
@ -44,7 +52,6 @@ class _DriftBackupPageState extends ConsumerState<DriftBackupPage> {
. toList ( ) ;
final backupNotifier = ref . read ( driftBackupProvider . notifier ) ;
final backgroundManager = ref . read ( backgroundSyncProvider ) ;
Future < void > startBackup ( ) async {
final currentUser = Store . tryGet ( StoreKey . currentUser ) ;
@ -52,7 +59,6 @@ class _DriftBackupPageState extends ConsumerState<DriftBackupPage> {
return ;
}
await backgroundManager . syncRemote ( ) ;
await backupNotifier . getBackupStatus ( currentUser . id ) ;
await backupNotifier . startBackup ( currentUser . id ) ;
}
@ -235,11 +241,13 @@ class _BackupCard extends ConsumerWidget {
@ override
Widget build ( BuildContext context , WidgetRef ref ) {
final backupCount = ref . watch ( driftBackupProvider . select ( ( p ) = > p . backupCount ) ) ;
final syncStatus = ref . watch ( syncStatusProvider ) ;
return BackupInfoCard (
title: " backup_controller_page_backup " . tr ( ) ,
subtitle: " backup_controller_page_backup_sub " . tr ( ) ,
info: backupCount . toString ( ) ,
isLoading: syncStatus . isRemoteSyncing ,
) ;
}
}
@ -250,10 +258,13 @@ class _RemainderCard extends ConsumerWidget {
@ override
Widget build ( BuildContext context , WidgetRef ref ) {
final remainderCount = ref . watch ( driftBackupProvider . select ( ( p ) = > p . remainderCount ) ) ;
final syncStatus = ref . watch ( syncStatusProvider ) ;
return BackupInfoCard (
title: " backup_controller_page_remainder " . tr ( ) ,
subtitle: " backup_controller_page_remainder_sub " . tr ( ) ,
info: remainderCount . toString ( ) ,
isLoading: syncStatus . isRemoteSyncing ,
onTap: ( ) = > context . pushRoute ( const DriftBackupAssetDetailRoute ( ) ) ,
) ;
}