Skip to content

Commit

Permalink
refactor: clamp download progress value to start from .05
Browse files Browse the repository at this point in the history
  • Loading branch information
Dr-Blank committed Sep 23, 2024
1 parent a5ec573 commit 84e5fd9
Showing 1 changed file with 19 additions and 17 deletions.
36 changes: 19 additions & 17 deletions lib/features/item_viewer/view/library_item_actions.dart
Original file line number Diff line number Diff line change
Expand Up @@ -222,21 +222,21 @@ class LibItemDownloadButton extends HookConsumerWidget {
final isItemDownloading = ref.watch(isItemDownloadingProvider(item.id));

return isItemDownloading
? ItemCurrentlyInDownloadQueue(
item: item,
)
: IconButton(
onPressed: () {
appLogger.fine('Pressed download button');

ref
.read(downloadManagerProvider.notifier)
.queueAudioBookDownload(item);
},
icon: const Icon(
Icons.download_rounded,
),
);
? ItemCurrentlyInDownloadQueue(
item: item,
)
: IconButton(
onPressed: () {
appLogger.fine('Pressed download button');

ref
.read(downloadManagerProvider.notifier)
.queueAudioBookDownload(item);
},
icon: const Icon(
Icons.download_rounded,
),
);
}
}

Expand All @@ -250,8 +250,10 @@ class ItemCurrentlyInDownloadQueue extends HookConsumerWidget {

@override
Widget build(BuildContext context, WidgetRef ref) {
final progress =
ref.watch(itemDownloadProgressProvider(item.id)).valueOrNull;
final progress = ref
.watch(itemDownloadProgressProvider(item.id))
.valueOrNull
?.clamp(0.05, 1.0);

if (progress == 1) {
return AlreadyItemDownloadedButton(item: item);
Expand Down

0 comments on commit 84e5fd9

Please sign in to comment.