mirror of
https://github.com/immich-app/immich
synced 2025-10-17 18:19:27 +00:00
fix: improve sync backup error indicator (#22527)
* 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>
This commit is contained in:
parent
3c5a125762
commit
212649edf9
8 changed files with 81 additions and 58 deletions
|
|
@ -6,11 +6,12 @@ import 'package:immich_mobile/utils/isolate.dart';
|
|||
import 'package:worker_manager/worker_manager.dart';
|
||||
|
||||
typedef SyncCallback = void Function();
|
||||
typedef SyncCallbackWithResult<T> = void Function(T result);
|
||||
typedef SyncErrorCallback = void Function(String error);
|
||||
|
||||
class BackgroundSyncManager {
|
||||
final SyncCallback? onRemoteSyncStart;
|
||||
final SyncCallback? onRemoteSyncComplete;
|
||||
final SyncCallbackWithResult<bool?>? onRemoteSyncComplete;
|
||||
final SyncErrorCallback? onRemoteSyncError;
|
||||
|
||||
final SyncCallback? onLocalSyncStart;
|
||||
|
|
@ -156,15 +157,18 @@ class BackgroundSyncManager {
|
|||
debugLabel: 'remote-sync',
|
||||
);
|
||||
return _syncTask!
|
||||
.then((result) => result ?? false)
|
||||
.whenComplete(() {
|
||||
onRemoteSyncComplete?.call();
|
||||
_syncTask = null;
|
||||
.then((result) {
|
||||
final success = result ?? false;
|
||||
onRemoteSyncComplete?.call(success);
|
||||
return success;
|
||||
})
|
||||
.catchError((error) {
|
||||
onRemoteSyncError?.call(error.toString());
|
||||
_syncTask = null;
|
||||
return false;
|
||||
})
|
||||
.whenComplete(() {
|
||||
_syncTask = null;
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue