1
0
mirror of https://github.com/immich-app/immich.git synced 2025-08-09 23:17:29 +02:00

feat(mobile): new sync (#16556)

* feat(mobile): new sync

* refactor

* refactor

* refactor

* refactor

* refactor

* refactor

* update analysis option

* remove database operation

* pr feedback
This commit is contained in:
Alex
2025-03-06 08:44:28 -06:00
committed by GitHub
parent 2875303b4c
commit 1ed1a0a1fc
7 changed files with 216 additions and 0 deletions

View File

@@ -0,0 +1,49 @@
import 'dart:async';
import 'package:flutter/foundation.dart';
import 'package:immich_mobile/domain/interfaces/sync_api.interface.dart';
import 'package:openapi/api.dart';
class SyncStreamService {
final ISyncApiRepository _syncApiRepository;
SyncStreamService(this._syncApiRepository);
StreamSubscription? _userSyncSubscription;
void syncUsers() {
_userSyncSubscription =
_syncApiRepository.watchUserSyncEvent().listen((events) async {
for (final event in events) {
if (event.data is SyncUserV1) {
final data = event.data as SyncUserV1;
debugPrint("User Update: $data");
// final user = await _userRepository.get(data.id);
// if (user == null) {
// continue;
// }
// user.name = data.name;
// user.email = data.email;
// user.updatedAt = DateTime.now();
// await _userRepository.update(user);
// await _syncApiRepository.ack(event.ack);
}
if (event.data is SyncUserDeleteV1) {
final data = event.data as SyncUserDeleteV1;
debugPrint("User delete: $data");
// await _syncApiRepository.ack(event.ack);
}
}
});
}
Future<void> dispose() async {
await _userSyncSubscription?.cancel();
}
}