handle LivePhotos progress

This commit is contained in:
Alex
2026-01-06 20:37:20 -06:00
parent b3750cee32
commit 4570f421cc
2 changed files with 9 additions and 5 deletions

View File

@@ -430,13 +430,17 @@ class DriftBackupNotifier extends StateNotifier<DriftBackupState> {
}
void _handleForegroundBackupProgress(String localAssetId, String filename, int bytes, int totalBytes) {
if (state.cancelToken == null) {
return;
}
final progress = totalBytes > 0 ? bytes / totalBytes : 0.0;
final currentItem = state.uploadItems[localAssetId];
if (currentItem != null) {
state = state.copyWith(
uploadItems: {
...state.uploadItems,
localAssetId: currentItem.copyWith(progress: progress, fileSize: totalBytes),
localAssetId: currentItem.copyWith(filename: filename, progress: progress, fileSize: totalBytes),
},
);
} else {

View File

@@ -194,7 +194,7 @@ class UploadService {
asset,
httpClient,
cancelToken,
(bytes, totalBytes) => onProgress(asset.localId!, asset.name, bytes, totalBytes),
onProgress,
onSuccess,
onError,
onICloudProgress: onICloudProgress,
@@ -221,7 +221,7 @@ class UploadService {
LocalAsset asset,
Client httpClient,
CancellationToken cancelToken,
void Function(int bytes, int totalBytes) onProgress,
void Function(String id, String filename, int bytes, int totalBytes) onProgress,
void Function(String localAssetId, String remoteAssetId) onSuccess,
void Function(String errorMessage) onError, {
void Function(String localAssetId, double progress)? onICloudProgress,
@@ -307,7 +307,7 @@ class UploadService {
fields: fields,
httpClient: httpClient,
cancelToken: cancelToken,
onProgress: onProgress,
onProgress: (bytes, totalBytes) => onProgress(asset.localId!, livePhotoTitle, bytes, totalBytes),
);
}
@@ -323,7 +323,7 @@ class UploadService {
fields: fields,
httpClient: httpClient,
cancelToken: cancelToken,
onProgress: onProgress,
onProgress: (bytes, totalBytes) => onProgress(asset.localId!, originalFileName, bytes, totalBytes),
);
if (result.isSuccess && result.remoteAssetId != null) {