mirror of
https://github.com/immich-app/immich.git
synced 2025-10-31 18:47:09 -04:00
* fix: improve sync indicator error * prefer backup disabled icon before error --------- Co-authored-by: shenlong-tanwen <139912620+shalong-tanwen@users.noreply.github.com> Co-authored-by: Alex <alex.tran1502@gmail.com>
30 lines
1.3 KiB
Dart
30 lines
1.3 KiB
Dart
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
|
import 'package:immich_mobile/domain/utils/background_sync.dart';
|
|
import 'package:immich_mobile/providers/backup/drift_backup.provider.dart';
|
|
import 'package:immich_mobile/providers/sync_status.provider.dart';
|
|
|
|
final backgroundSyncProvider = Provider<BackgroundSyncManager>((ref) {
|
|
final syncStatusNotifier = ref.read(syncStatusProvider.notifier);
|
|
final backupProvider = ref.read(driftBackupProvider.notifier);
|
|
|
|
final manager = BackgroundSyncManager(
|
|
onRemoteSyncStart: () {
|
|
syncStatusNotifier.startRemoteSync();
|
|
backupProvider.updateError(BackupError.none);
|
|
},
|
|
onRemoteSyncComplete: (isSuccess) {
|
|
syncStatusNotifier.completeRemoteSync();
|
|
backupProvider.updateError(isSuccess == true ? BackupError.none : BackupError.syncFailed);
|
|
},
|
|
onRemoteSyncError: syncStatusNotifier.errorRemoteSync,
|
|
onLocalSyncStart: syncStatusNotifier.startLocalSync,
|
|
onLocalSyncComplete: syncStatusNotifier.completeLocalSync,
|
|
onLocalSyncError: syncStatusNotifier.errorLocalSync,
|
|
onHashingStart: syncStatusNotifier.startHashJob,
|
|
onHashingComplete: syncStatusNotifier.completeHashJob,
|
|
onHashingError: syncStatusNotifier.errorHashJob,
|
|
);
|
|
ref.onDispose(manager.cancel);
|
|
return manager;
|
|
});
|