Skip to content

A cross platform Audiobookshelf client for Android and iOS

Dart

Stop the downloading toast counting episodes you deleted, so it stops showing on every launch

Barnabas3fa833ee9cef
diff --git a/lib/providers/_lp_core.dart b/lib/providers/_lp_core.dart
index a0a696f1..add0ff4d 100644
--- a/lib/providers/_lp_core.dart
+++ b/lib/providers/_lp_core.dart
@@ -3450,7 +3450,8 @@ mixin _CoreMixin on ChangeNotifier, _StateMixin {
final anchorFinished = _progressMap[compoundKey]?['isFinished'] == true;
if (!anchorFinished &&
!dl.isDownloaded(compoundKey) &&
- !dl.isDownloading(compoundKey)) {
+ !dl.isDownloading(compoundKey) &&
+ !dl.isAutoDownloadBlocked(compoundKey)) {
final curEp = episodes[currentIdx] as Map<String, dynamic>;
dl.downloadItem(
api: _api!,
@@ -3477,6 +3478,10 @@ mixin _CoreMixin on ChangeNotifier, _StateMixin {
continue;
}
if (_progressMap[key]?['isFinished'] == true) continue;
+ // Deleted by hand: downloadItem would skip it anyway, and counting it
+ // here is what announced "Downloading 2 episodes" on every launch while
+ // nothing downloaded.
+ if (dl.isAutoDownloadBlocked(key)) continue;
dl.downloadItem(
api: _api!,
diff --git a/lib/services/download_service.dart b/lib/services/download_service.dart
index 6a8e671c..e72f6eb6 100644
--- a/lib/services/download_service.dart
+++ b/lib/services/download_service.dart
@@ -351,6 +351,12 @@ class DownloadService extends ChangeNotifier {
// these, so a half-finished book that was deleted stops coming back on the
// next launch. Global like the downloads themselves, not per account.
final Set<String> _autoDownloadBlocked = {};
+
+ /// True when the user deleted this download, so an automatic download of it
+ /// would be skipped. Callers that count or announce downloads need to know
+ /// before they call, or they announce work that never happens.
+ bool isAutoDownloadBlocked(String itemId) =>
+ _autoDownloadBlocked.contains(itemId);
static const _autoDownloadBlockedKey = 'auto_download_blocked';
/// The current Android SAF folder URI (content://), or null if using default.