Add sync status to app drawer

This commit is contained in:
2026-02-06 20:43:26 +01:00
parent 7ec7b20e74
commit 9261ec341e
3 changed files with 67 additions and 13 deletions

View File

@@ -11,12 +11,16 @@ class SyncResult {
final bool isOnline;
final int changesSynced;
final int annotationsSynced;
final int changesUnsynced;
final int annotationsUnsynced;
SyncResult({
required this.sheets,
required this.isOnline,
this.changesSynced = 0,
this.annotationsSynced = 0,
required this.changesSynced,
required this.annotationsSynced,
required this.changesUnsynced,
required this.annotationsUnsynced,
});
}
@@ -35,8 +39,8 @@ class SyncService {
SyncService({
required ApiClient apiClient,
required StorageService storageService,
}) : _apiClient = apiClient,
_storageService = storageService;
}) : _apiClient = apiClient,
_storageService = storageService;
/// Performs a full sync operation.
///
@@ -80,6 +84,8 @@ class SyncService {
// 3. Upload pending annotations
annotationsSynced = await _uploadPendingAnnotations();
final remainingAnnotations = await _storageService
.readPendingAnnotationUploads();
// 4. Apply any remaining local changes (in case some failed to upload)
final changeQueue = await _storageService.readChangeQueue();
@@ -102,6 +108,8 @@ class SyncService {
isOnline: true,
changesSynced: changesSynced,
annotationsSynced: annotationsSynced,
changesUnsynced: changeQueue.length,
annotationsUnsynced: remainingAnnotations.length,
);
}
@@ -127,9 +135,16 @@ class SyncService {
}
}
final remainingAnnotations = await _storageService
.readPendingAnnotationUploads();
return SyncResult(
sheets: sheets,
isOnline: false,
changesSynced: 0,
annotationsSynced: 0,
changesUnsynced: changeQueue.length,
annotationsUnsynced: remainingAnnotations.length,
);
}