refactor: clamp download progress value to start from .05

This commit is contained in:
Dr-Blank 2024-09-23 04:28:08 -04:00
parent a5ec573a76
commit 84e5fd9d81
No known key found for this signature in database
GPG key ID: 7452CC63F210A266

View file

@ -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');
? ItemCurrentlyInDownloadQueue(
item: item,
)
: IconButton(
onPressed: () {
appLogger.fine('Pressed download button');
ref
.read(downloadManagerProvider.notifier)
.queueAudioBookDownload(item);
},
icon: const Icon(
Icons.download_rounded,
),
);
ref
.read(downloadManagerProvider.notifier)
.queueAudioBookDownload(item);
},
icon: const Icon(
Icons.download_rounded,
),
);
}
}
@ -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);