sheets view: add refresh button for annotations
This commit is contained in:
@@ -15,24 +15,26 @@ class AnnotationSyncService {
|
||||
AnnotationSyncService({
|
||||
required ApiClient apiClient,
|
||||
required StorageService storageService,
|
||||
}) : _apiClient = apiClient,
|
||||
_storageService = storageService;
|
||||
}) : _apiClient = apiClient,
|
||||
_storageService = storageService;
|
||||
|
||||
/// Downloads annotations from server and merges with local storage.
|
||||
///
|
||||
/// For each page, compares server's lastModified with local lastModified.
|
||||
/// If server is newer, overwrites local. Local annotations that are newer
|
||||
/// are preserved.
|
||||
Future<void> syncFromServer(String sheetUuid) async {
|
||||
Future<void> syncAnnotationsFromServer(String sheetUuid) async {
|
||||
try {
|
||||
_log.info('Syncing annotations from server for sheet $sheetUuid');
|
||||
|
||||
// Fetch all annotations from server
|
||||
final serverAnnotations = await _apiClient.fetchAnnotations(sheetUuid);
|
||||
|
||||
_log.fine('Fetched annotations from server for sheet $sheetUuid');
|
||||
|
||||
// Get all local annotations with metadata
|
||||
final localAnnotations =
|
||||
await _storageService.readAllAnnotationsWithMetadata(sheetUuid);
|
||||
final localAnnotations = await _storageService
|
||||
.readAllAnnotationsWithMetadata(sheetUuid);
|
||||
|
||||
int updatedCount = 0;
|
||||
|
||||
@@ -118,7 +120,8 @@ class AnnotationSyncService {
|
||||
return false;
|
||||
} catch (e) {
|
||||
_log.warning(
|
||||
'Unexpected error uploading annotation, queuing for later: $e');
|
||||
'Unexpected error uploading annotation, queuing for later: $e',
|
||||
);
|
||||
await _queueForLaterUpload(
|
||||
sheetUuid: sheetUuid,
|
||||
page: page,
|
||||
|
||||
Reference in New Issue
Block a user