feat(mobile): assets + exif stream sync placeholder (#17677)

* feat(mobile): assets + exif stream sync placeholder

* feat(mobile): assets + exif stream sync placeholder

* refactor

* fix: test

* fix:test

* refactor(mobile): sync stream service (#17687)

* refactor: sync stream to use callbacks

* pr feedback

* pr feedback

* pr feedback

* fix: test

---------

Co-authored-by: shenlong-tanwen <139912620+shalong-tanwen@users.noreply.github.com>
Co-authored-by: Alex Tran <alex.tran1502@gmail.com>

---------

Co-authored-by: shenlong <139912620+shenlong-tanwen@users.noreply.github.com>
Co-authored-by: shenlong-tanwen <139912620+shalong-tanwen@users.noreply.github.com>
This commit is contained in:
Alex 2025-04-18 14:01:16 -05:00 committed by GitHub
parent bd2deda50c
commit 0e6ac87645
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
11 changed files with 666 additions and 608 deletions

View file

@ -7,31 +7,33 @@ import 'package:immich_mobile/utils/isolate.dart';
import 'package:worker_manager/worker_manager.dart';
class BackgroundSyncManager {
Cancelable<void>? _userSyncTask;
Cancelable<void>? _syncTask;
BackgroundSyncManager();
Future<void> cancel() {
final futures = <Future>[];
if (_userSyncTask != null) {
futures.add(_userSyncTask!.future);
if (_syncTask != null) {
futures.add(_syncTask!.future);
}
_userSyncTask?.cancel();
_userSyncTask = null;
_syncTask?.cancel();
_syncTask = null;
return Future.wait(futures);
}
Future<void> syncUsers() {
if (_userSyncTask != null) {
return _userSyncTask!.future;
Future<void> sync() {
if (_syncTask != null) {
return _syncTask!.future;
}
_userSyncTask = runInIsolateGentle(
computation: (ref) => ref.read(syncStreamServiceProvider).syncUsers(),
_syncTask = runInIsolateGentle(
computation: (ref) => ref.read(syncStreamServiceProvider).sync(),
);
_userSyncTask!.whenComplete(() {
_userSyncTask = null;
_syncTask!.whenComplete(() {
_syncTask = null;
});
return _userSyncTask!.future;
return _syncTask!.future;
}
}