You've already forked immich
mirror of
https://github.com/immich-app/immich.git
synced 2025-08-08 23:07:06 +02:00
feat: websocket background sync (#19888)
* feat: websocket background sync * batch websocket * pr feedback
This commit is contained in:
@ -6,6 +6,7 @@ import 'package:worker_manager/worker_manager.dart';
|
||||
|
||||
class BackgroundSyncManager {
|
||||
Cancelable<void>? _syncTask;
|
||||
Cancelable<void>? _syncWebsocketTask;
|
||||
Cancelable<void>? _deviceAlbumSyncTask;
|
||||
Cancelable<void>? _hashTask;
|
||||
|
||||
@ -20,6 +21,12 @@ class BackgroundSyncManager {
|
||||
_syncTask?.cancel();
|
||||
_syncTask = null;
|
||||
|
||||
if (_syncWebsocketTask != null) {
|
||||
futures.add(_syncWebsocketTask!.future);
|
||||
}
|
||||
_syncWebsocketTask?.cancel();
|
||||
_syncWebsocketTask = null;
|
||||
|
||||
return Future.wait(futures);
|
||||
}
|
||||
|
||||
@ -72,4 +79,19 @@ class BackgroundSyncManager {
|
||||
_syncTask = null;
|
||||
});
|
||||
}
|
||||
|
||||
Future<void> syncWebsocketBatch(List<dynamic> batchData) {
|
||||
if (_syncWebsocketTask != null) {
|
||||
return _syncWebsocketTask!.future;
|
||||
}
|
||||
|
||||
_syncWebsocketTask = runInIsolateGentle(
|
||||
computation: (ref) => ref
|
||||
.read(syncStreamServiceProvider)
|
||||
.handleWsAssetUploadReadyV1Batch(batchData),
|
||||
);
|
||||
return _syncWebsocketTask!.whenComplete(() {
|
||||
_syncWebsocketTask = null;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user