feat(mobile): beta sync stats page (#19950)
* show beta sync stats * show status next to jobs * use drift devtools reset database impl * dcm fixes * fix: hash count * styling --------- Co-authored-by: Alex <alex.tran1502@gmail.com>
This commit is contained in:
@@ -76,4 +76,15 @@ class AssetService {
|
||||
Future<List<(String, String)>> getPlaces() {
|
||||
return _remoteAssetRepository.getPlaces();
|
||||
}
|
||||
|
||||
Future<(int local, int remote)> getAssetCounts() async {
|
||||
return (
|
||||
await _localAssetRepository.getCount(),
|
||||
await _remoteAssetRepository.getCount()
|
||||
);
|
||||
}
|
||||
|
||||
Future<int> getLocalHashedCount() {
|
||||
return _localAssetRepository.getHashedCount();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,4 +18,8 @@ class LocalAlbumService {
|
||||
Future<void> update(LocalAlbum album) {
|
||||
return _repository.upsert(album);
|
||||
}
|
||||
|
||||
Future<int> getCount() {
|
||||
return _repository.getCount();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,4 +12,8 @@ class DriftMemoryService {
|
||||
Future<List<DriftMemory>> getMemoryLane(String ownerId) {
|
||||
return _repository.getAll(ownerId);
|
||||
}
|
||||
|
||||
Future<int> getCount() {
|
||||
return _repository.getCount();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -147,4 +147,8 @@ class RemoteAlbumService {
|
||||
|
||||
return _repository.addUsers(albumId, userIds);
|
||||
}
|
||||
|
||||
Future<int> getCount() {
|
||||
return _repository.getCount();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,6 +12,14 @@ class BackgroundSyncManager {
|
||||
final SyncCallback? onRemoteSyncComplete;
|
||||
final SyncErrorCallback? onRemoteSyncError;
|
||||
|
||||
final SyncCallback? onLocalSyncStart;
|
||||
final SyncCallback? onLocalSyncComplete;
|
||||
final SyncErrorCallback? onLocalSyncError;
|
||||
|
||||
final SyncCallback? onHashingStart;
|
||||
final SyncCallback? onHashingComplete;
|
||||
final SyncErrorCallback? onHashingError;
|
||||
|
||||
Cancelable<void>? _syncTask;
|
||||
Cancelable<void>? _syncWebsocketTask;
|
||||
Cancelable<void>? _deviceAlbumSyncTask;
|
||||
@@ -21,6 +29,12 @@ class BackgroundSyncManager {
|
||||
this.onRemoteSyncStart,
|
||||
this.onRemoteSyncComplete,
|
||||
this.onRemoteSyncError,
|
||||
this.onLocalSyncStart,
|
||||
this.onLocalSyncComplete,
|
||||
this.onLocalSyncError,
|
||||
this.onHashingStart,
|
||||
this.onHashingComplete,
|
||||
this.onHashingError,
|
||||
});
|
||||
|
||||
Future<void> cancel() {
|
||||
@@ -47,6 +61,8 @@ class BackgroundSyncManager {
|
||||
return _deviceAlbumSyncTask!.future;
|
||||
}
|
||||
|
||||
onLocalSyncStart?.call();
|
||||
|
||||
// We use a ternary operator to avoid [_deviceAlbumSyncTask] from being
|
||||
// captured by the closure passed to [runInIsolateGentle].
|
||||
_deviceAlbumSyncTask = full
|
||||
@@ -61,6 +77,10 @@ class BackgroundSyncManager {
|
||||
|
||||
return _deviceAlbumSyncTask!.whenComplete(() {
|
||||
_deviceAlbumSyncTask = null;
|
||||
onLocalSyncComplete?.call();
|
||||
}).catchError((error) {
|
||||
onLocalSyncError?.call(error.toString());
|
||||
_deviceAlbumSyncTask = null;
|
||||
});
|
||||
}
|
||||
|
||||
@@ -70,10 +90,17 @@ class BackgroundSyncManager {
|
||||
return _hashTask!.future;
|
||||
}
|
||||
|
||||
onHashingStart?.call();
|
||||
|
||||
_hashTask = runInIsolateGentle(
|
||||
computation: (ref) => ref.read(hashServiceProvider).hashAssets(),
|
||||
);
|
||||
|
||||
return _hashTask!.whenComplete(() {
|
||||
onHashingComplete?.call();
|
||||
_hashTask = null;
|
||||
}).catchError((error) {
|
||||
onHashingError?.call(error.toString());
|
||||
_hashTask = null;
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user