mirror of
https://github.com/Dr-Blank/Vaani.git
synced 2025-12-14 06:59:29 +00:00
refactor: clamp download progress value to start from .05
This commit is contained in:
parent
a5ec573a76
commit
84e5fd9d81
1 changed files with 18 additions and 16 deletions
|
|
@ -222,21 +222,21 @@ class LibItemDownloadButton extends HookConsumerWidget {
|
||||||
final isItemDownloading = ref.watch(isItemDownloadingProvider(item.id));
|
final isItemDownloading = ref.watch(isItemDownloadingProvider(item.id));
|
||||||
|
|
||||||
return isItemDownloading
|
return isItemDownloading
|
||||||
? ItemCurrentlyInDownloadQueue(
|
? ItemCurrentlyInDownloadQueue(
|
||||||
item: item,
|
item: item,
|
||||||
)
|
)
|
||||||
: IconButton(
|
: IconButton(
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
appLogger.fine('Pressed download button');
|
appLogger.fine('Pressed download button');
|
||||||
|
|
||||||
ref
|
ref
|
||||||
.read(downloadManagerProvider.notifier)
|
.read(downloadManagerProvider.notifier)
|
||||||
.queueAudioBookDownload(item);
|
.queueAudioBookDownload(item);
|
||||||
},
|
},
|
||||||
icon: const Icon(
|
icon: const Icon(
|
||||||
Icons.download_rounded,
|
Icons.download_rounded,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -250,8 +250,10 @@ class ItemCurrentlyInDownloadQueue extends HookConsumerWidget {
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context, WidgetRef ref) {
|
Widget build(BuildContext context, WidgetRef ref) {
|
||||||
final progress =
|
final progress = ref
|
||||||
ref.watch(itemDownloadProgressProvider(item.id)).valueOrNull;
|
.watch(itemDownloadProgressProvider(item.id))
|
||||||
|
.valueOrNull
|
||||||
|
?.clamp(0.05, 1.0);
|
||||||
|
|
||||||
if (progress == 1) {
|
if (progress == 1) {
|
||||||
return AlreadyItemDownloadedButton(item: item);
|
return AlreadyItemDownloadedButton(item: item);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue