diff --git a/mobile/lib/pages/common/download_panel.dart b/mobile/lib/pages/common/download_panel.dart index ccaac0c9e2..596e6913d0 100644 --- a/mobile/lib/pages/common/download_panel.dart +++ b/mobile/lib/pages/common/download_panel.dart @@ -65,7 +65,6 @@ class DownloadTaskTile extends StatelessWidget { @override Widget build(BuildContext context) { final isComplete = status == TaskStatus.complete; - final doneColor = context.isDarkTheme ? Colors.green[200] : Colors.green[400]; final progressPercent = (progress * 100).round(); String getStatusText() => switch (status) { @@ -92,8 +91,7 @@ class DownloadTaskTile extends StatelessWidget { trailing: IconButton( icon: Icon( isComplete ? Icons.download_done : Icons.close, - color: isComplete ? doneColor : context.colorScheme.onError, - size: isComplete ? 28 : null, + color: isComplete ? context.colorScheme.primary : context.colorScheme.onError, ), onPressed: onCancelDownload, style: isComplete diff --git a/mobile/lib/providers/asset_viewer/download.provider.dart b/mobile/lib/providers/asset_viewer/download.provider.dart index a55dcf4564..ba72ef60c5 100644 --- a/mobile/lib/providers/asset_viewer/download.provider.dart +++ b/mobile/lib/providers/asset_viewer/download.provider.dart @@ -20,28 +20,23 @@ class DownloadStateNotifier extends StateNotifier { _downloadService.onTaskProgress = _taskProgressCallback; } - void _updateDownloadStatus(String taskId, TaskStatus status) { - if (status == TaskStatus.canceled) { + void _downloadStatusCallback(TaskStatusUpdate update) { + if (update.status == TaskStatus.canceled) { + return; + } + + final existing = state.taskProgress[update.task.taskId]; + if (existing == null) { return; } state = state.copyWith( taskProgress: {} ..addAll(state.taskProgress) - ..addAll({ - taskId: DownloadInfo( - progress: state.taskProgress[taskId]?.progress ?? 0, - fileName: state.taskProgress[taskId]?.fileName ?? '', - status: status, - ), - }), + ..addAll({update.task.taskId: existing.copyWith(status: update.status)}), ); } - void _downloadStatusCallback(TaskStatusUpdate update) { - _updateDownloadStatus(update.task.taskId, update.status); - } - void _taskProgressCallback(TaskProgressUpdate update) { // Ignore if the task is canceled or completed if (update.progress == -2 || update.progress == -1) { diff --git a/mobile/lib/services/download.service.dart b/mobile/lib/services/download.service.dart index e46258361b..09a56f0ce9 100644 --- a/mobile/lib/services/download.service.dart +++ b/mobile/lib/services/download.service.dart @@ -67,7 +67,6 @@ class DownloadService { onVideoDownloadStatus?.call(update); } - // UI-only; saves stay on the DB record stream (#29900) void _onLivePhotoDownloadCallback(TaskStatusUpdate update) { onLivePhotoDownloadStatus?.call(update); } diff --git a/mobile/test/providers/asset_viewer/download_provider_test.dart b/mobile/test/providers/asset_viewer/download_provider_test.dart index bfccd29080..2e2694475d 100644 --- a/mobile/test/providers/asset_viewer/download_provider_test.dart +++ b/mobile/test/providers/asset_viewer/download_provider_test.dart @@ -101,4 +101,13 @@ void main() { expect(notifier.state.taskProgress.containsKey('ghost'), isFalse); }); }); + + test('a status for an unknown task does not create an entry', () { + fakeAsync((async) { + onImage(TaskStatusUpdate(_task('ghost'), TaskStatus.complete)); + + expect(notifier.state.taskProgress, isEmpty); + expect(notifier.state.showProgress, isFalse); + }); + }); }