A cross platform Audiobookshelf client for Android and iOS
Dart
Add a setting to auto-download the rest of a series when you start a book in it
Barnabas9404b5afe0dd
diff --git a/lib/providers/_lp_core.dart b/lib/providers/_lp_core.dartindex a5bf5931..3de162f6 100644--- a/lib/providers/_lp_core.dart+++ b/lib/providers/_lp_core.dart@@ -2021,9 +2021,12 @@ mixin _CoreMixin on ChangeNotifier, _StateMixin {}void _checkRollingDownloads(String playingKey) async {- if (_api == null || isOffline || _rollingDownloadSeries.isEmpty) {- return;- }+ if (_api == null || isOffline) return;+ // With the "auto series download" default on, a book in a series enables+ // rolling download for that series on first play (books only).+ final autoSeriesDefault =+ await PlayerSettings.getAutoSeriesDownloadDefault();+ if (_rollingDownloadSeries.isEmpty && !autoSeriesDefault) return;final count = await PlayerSettings.getRollingDownloadCount();if (playingKey.length > 36) {@@ -2040,7 +2043,13 @@ mixin _CoreMixin on ChangeNotifier, _StateMixin {(seriesId, _) = _StateMixin._extractSeries(fullItem);}}- if (seriesId != null && _rollingDownloadSeries.contains(seriesId)) {+ if (seriesId == null) return;+ if (autoSeriesDefault && !_rollingDownloadSeries.contains(seriesId)) {+ _rollingDownloadSeries.add(seriesId);+ await _saveRollingDownloadSeries();+ notifyListeners();+ }+ if (_rollingDownloadSeries.contains(seriesId)) {_rollingDownloadBook(playingKey, count);}}diff --git a/lib/screens/settings_screen.dart b/lib/screens/settings_screen.dartindex 8e2017b2..9b8957b9 100644--- a/lib/screens/settings_screen.dart+++ b/lib/screens/settings_screen.dart@@ -109,6 +109,7 @@ class _SettingsScreenState extends State<SettingsScreen> {bool _loggingEnabled = false;bool _fullScreenPlayer = false;bool _lockPortrait = false;+ bool _autoSeriesDownloadDefault = false;// card button layout is now managed in the edit sheet (more menu)bool _snappyTransitions = false;bool _classicWording = false;@@ -703,9 +704,11 @@ class _SettingsScreenState extends State<SettingsScreen> {final rmabApiToken = await ScopedPrefs.getString(kRmabApiTokenKey);final sleepRewind = await PlayerSettings.getSleepRewindSeconds();final lockPortrait = await PlayerSettings.getLockPortrait();+ final autoSeriesDownload = await PlayerSettings.getAutoSeriesDownloadDefault();if (mounted) setState(() {_sleepRewindSeconds = sleepRewind;_lockPortrait = lockPortrait;+ _autoSeriesDownloadDefault = autoSeriesDownload;_rmabBaseUrl = rmabBaseUrl;_rmabApiToken = rmabApiToken;_rewindSettings = s;@@ -2496,6 +2499,20 @@ class _SettingsScreenState extends State<SettingsScreen> {} : null,),const Divider(height: 1, indent: 16, endIndent: 16),+ SwitchListTile(+ title: const Text('Auto-download series'),+ subtitle: Text(+ _autoSeriesDownloadDefault+ ? 'Starting a book in a series keeps the next books downloaded'+ : 'Turn on series downloads yourself from the series menu',+ style: tt.bodySmall?.copyWith(color: cs.onSurfaceVariant)),+ value: _autoSeriesDownloadDefault,+ onChanged: _loaded ? (v) {+ setState(() => _autoSeriesDownloadDefault = v);+ PlayerSettings.setAutoSeriesDownloadDefault(v);+ } : null,+ ),+ const Divider(height: 1, indent: 16, endIndent: 16),Padding(padding: const EdgeInsets.symmetric(horizontal: 16),child: Column(diff --git a/lib/services/player_settings.dart b/lib/services/player_settings.dartindex b70820f3..c9a6028d 100644--- a/lib/services/player_settings.dart+++ b/lib/services/player_settings.dart@@ -143,6 +143,12 @@ class PlayerSettings {static Future<bool> getAutoDownloadOnStream() => _get('autoDownloadOnStream', false);static Future<void> setAutoDownloadOnStream(bool value) => _set('autoDownloadOnStream', value);+ /// When on, starting a book that's part of a series automatically turns on+ /// series auto-download for that series (the same per-series toggle shown in+ /// the series sheet). Default off.+ static Future<bool> getAutoSeriesDownloadDefault() => _get('autoSeriesDownloadDefault', false);+ static Future<void> setAutoSeriesDownloadDefault(bool value) => _set('autoSeriesDownloadDefault', value);+/// Bookmark sort: 'newest' (default) or 'position'static Future<String> getBookmarkSort() => _get('bookmarkSort', 'newest');static Future<void> setBookmarkSort(String value) => _set('bookmarkSort', value);