Skip to content

A cross platform Audiobookshelf client for Android and iOS

Dart

Choose where new episodes of a subscribed podcast go in your queue

Barnabas96cbabf88509
diff --git a/lib/l10n/app_en.arb b/lib/l10n/app_en.arb
index db40c9db..98293572 100644
--- a/lib/l10n/app_en.arb
+++ b/lib/l10n/app_en.arb
@@ -3292,6 +3292,34 @@
}
}
},
+ "lpSubscribedEpisodeAddedStart": "{showTitle} added to the top of your queue",
+ "@lpSubscribedEpisodeAddedStart": {
+ "placeholders": {
+ "showTitle": {
+ "type": "String"
+ }
+ }
+ },
+ "lpSubscribedEpisodeAddedSecond": "{showTitle} added 2nd in your queue",
+ "@lpSubscribedEpisodeAddedSecond": {
+ "placeholders": {
+ "showTitle": {
+ "type": "String"
+ }
+ }
+ },
+ "lpSubscribedEpisodeAddedEnd": "{showTitle} added to the end of your queue",
+ "@lpSubscribedEpisodeAddedEnd": {
+ "placeholders": {
+ "showTitle": {
+ "type": "String"
+ }
+ }
+ },
+ "episodeListNewEpisodePosition": "New episode position",
+ "episodeListPositionTop": "Top of queue",
+ "episodeListPositionSecond": "Second in queue",
+ "episodeListPositionEnd": "End of queue",
"lpQueueDownloadingItems": "{count, plural, =1{Queue: downloading 1 item} other{Queue: downloading {count} items}}",
"@lpQueueDownloadingItems": {
"placeholders": {
diff --git a/lib/l10n/app_localizations.dart b/lib/l10n/app_localizations.dart
index efb37ea1..d7c5d426 100644
--- a/lib/l10n/app_localizations.dart
+++ b/lib/l10n/app_localizations.dart
@@ -9567,6 +9567,48 @@ abstract class AppLocalizations {
/// **'{showTitle}: {count, plural, =1{1 new episode downloading} other{{count} new episodes downloading}}'**
String lpSubscribedPodcastDownloading(String showTitle, int count);
+ /// No description provided for @lpSubscribedEpisodeAddedStart.
+ ///
+ /// In en, this message translates to:
+ /// **'{showTitle} added to the top of your queue'**
+ String lpSubscribedEpisodeAddedStart(String showTitle);
+
+ /// No description provided for @lpSubscribedEpisodeAddedSecond.
+ ///
+ /// In en, this message translates to:
+ /// **'{showTitle} added 2nd in your queue'**
+ String lpSubscribedEpisodeAddedSecond(String showTitle);
+
+ /// No description provided for @lpSubscribedEpisodeAddedEnd.
+ ///
+ /// In en, this message translates to:
+ /// **'{showTitle} added to the end of your queue'**
+ String lpSubscribedEpisodeAddedEnd(String showTitle);
+
+ /// No description provided for @episodeListNewEpisodePosition.
+ ///
+ /// In en, this message translates to:
+ /// **'New episode position'**
+ String get episodeListNewEpisodePosition;
+
+ /// No description provided for @episodeListPositionTop.
+ ///
+ /// In en, this message translates to:
+ /// **'Top of queue'**
+ String get episodeListPositionTop;
+
+ /// No description provided for @episodeListPositionSecond.
+ ///
+ /// In en, this message translates to:
+ /// **'Second in queue'**
+ String get episodeListPositionSecond;
+
+ /// No description provided for @episodeListPositionEnd.
+ ///
+ /// In en, this message translates to:
+ /// **'End of queue'**
+ String get episodeListPositionEnd;
+
/// No description provided for @lpQueueDownloadingItems.
///
/// In en, this message translates to:
diff --git a/lib/l10n/app_localizations_de.dart b/lib/l10n/app_localizations_de.dart
index 5e025033..2f945ae4 100644
--- a/lib/l10n/app_localizations_de.dart
+++ b/lib/l10n/app_localizations_de.dart
@@ -5527,6 +5527,33 @@ class AppLocalizationsDe extends AppLocalizations {
return '$showTitle: $_temp0';
}
+ @override
+ String lpSubscribedEpisodeAddedStart(String showTitle) {
+ return '$showTitle added to the top of your queue';
+ }
+
+ @override
+ String lpSubscribedEpisodeAddedSecond(String showTitle) {
+ return '$showTitle added 2nd in your queue';
+ }
+
+ @override
+ String lpSubscribedEpisodeAddedEnd(String showTitle) {
+ return '$showTitle added to the end of your queue';
+ }
+
+ @override
+ String get episodeListNewEpisodePosition => 'New episode position';
+
+ @override
+ String get episodeListPositionTop => 'Top of queue';
+
+ @override
+ String get episodeListPositionSecond => 'Second in queue';
+
+ @override
+ String get episodeListPositionEnd => 'End of queue';
+
@override
String lpQueueDownloadingItems(int count) {
String _temp0 = intl.Intl.pluralLogic(
diff --git a/lib/l10n/app_localizations_el.dart b/lib/l10n/app_localizations_el.dart
index 1f75efe5..35d01dce 100644
--- a/lib/l10n/app_localizations_el.dart
+++ b/lib/l10n/app_localizations_el.dart
@@ -5465,6 +5465,33 @@ class AppLocalizationsEl extends AppLocalizations {
return '$showTitle: $_temp0';
}
+ @override
+ String lpSubscribedEpisodeAddedStart(String showTitle) {
+ return '$showTitle added to the top of your queue';
+ }
+
+ @override
+ String lpSubscribedEpisodeAddedSecond(String showTitle) {
+ return '$showTitle added 2nd in your queue';
+ }
+
+ @override
+ String lpSubscribedEpisodeAddedEnd(String showTitle) {
+ return '$showTitle added to the end of your queue';
+ }
+
+ @override
+ String get episodeListNewEpisodePosition => 'New episode position';
+
+ @override
+ String get episodeListPositionTop => 'Top of queue';
+
+ @override
+ String get episodeListPositionSecond => 'Second in queue';
+
+ @override
+ String get episodeListPositionEnd => 'End of queue';
+
@override
String lpQueueDownloadingItems(int count) {
String _temp0 = intl.Intl.pluralLogic(
diff --git a/lib/l10n/app_localizations_en.dart b/lib/l10n/app_localizations_en.dart
index 305d63b2..7886ba76 100644
--- a/lib/l10n/app_localizations_en.dart
+++ b/lib/l10n/app_localizations_en.dart
@@ -5465,6 +5465,33 @@ class AppLocalizationsEn extends AppLocalizations {
return '$showTitle: $_temp0';
}
+ @override
+ String lpSubscribedEpisodeAddedStart(String showTitle) {
+ return '$showTitle added to the top of your queue';
+ }
+
+ @override
+ String lpSubscribedEpisodeAddedSecond(String showTitle) {
+ return '$showTitle added 2nd in your queue';
+ }
+
+ @override
+ String lpSubscribedEpisodeAddedEnd(String showTitle) {
+ return '$showTitle added to the end of your queue';
+ }
+
+ @override
+ String get episodeListNewEpisodePosition => 'New episode position';
+
+ @override
+ String get episodeListPositionTop => 'Top of queue';
+
+ @override
+ String get episodeListPositionSecond => 'Second in queue';
+
+ @override
+ String get episodeListPositionEnd => 'End of queue';
+
@override
String lpQueueDownloadingItems(int count) {
String _temp0 = intl.Intl.pluralLogic(
diff --git a/lib/l10n/app_localizations_es.dart b/lib/l10n/app_localizations_es.dart
index 4b7a92a1..0ad907b8 100644
--- a/lib/l10n/app_localizations_es.dart
+++ b/lib/l10n/app_localizations_es.dart
@@ -5465,6 +5465,33 @@ class AppLocalizationsEs extends AppLocalizations {
return '$showTitle: $_temp0';
}
+ @override
+ String lpSubscribedEpisodeAddedStart(String showTitle) {
+ return '$showTitle added to the top of your queue';
+ }
+
+ @override
+ String lpSubscribedEpisodeAddedSecond(String showTitle) {
+ return '$showTitle added 2nd in your queue';
+ }
+
+ @override
+ String lpSubscribedEpisodeAddedEnd(String showTitle) {
+ return '$showTitle added to the end of your queue';
+ }
+
+ @override
+ String get episodeListNewEpisodePosition => 'New episode position';
+
+ @override
+ String get episodeListPositionTop => 'Top of queue';
+
+ @override
+ String get episodeListPositionSecond => 'Second in queue';
+
+ @override
+ String get episodeListPositionEnd => 'End of queue';
+
@override
String lpQueueDownloadingItems(int count) {
String _temp0 = intl.Intl.pluralLogic(
diff --git a/lib/l10n/app_localizations_fr.dart b/lib/l10n/app_localizations_fr.dart
index c7b5bdda..b5bd07c1 100644
--- a/lib/l10n/app_localizations_fr.dart
+++ b/lib/l10n/app_localizations_fr.dart
@@ -5467,6 +5467,33 @@ class AppLocalizationsFr extends AppLocalizations {
return '$showTitle: $_temp0';
}
+ @override
+ String lpSubscribedEpisodeAddedStart(String showTitle) {
+ return '$showTitle added to the top of your queue';
+ }
+
+ @override
+ String lpSubscribedEpisodeAddedSecond(String showTitle) {
+ return '$showTitle added 2nd in your queue';
+ }
+
+ @override
+ String lpSubscribedEpisodeAddedEnd(String showTitle) {
+ return '$showTitle added to the end of your queue';
+ }
+
+ @override
+ String get episodeListNewEpisodePosition => 'New episode position';
+
+ @override
+ String get episodeListPositionTop => 'Top of queue';
+
+ @override
+ String get episodeListPositionSecond => 'Second in queue';
+
+ @override
+ String get episodeListPositionEnd => 'End of queue';
+
@override
String lpQueueDownloadingItems(int count) {
String _temp0 = intl.Intl.pluralLogic(
diff --git a/lib/l10n/app_localizations_it.dart b/lib/l10n/app_localizations_it.dart
index e36e623a..65e76167 100644
--- a/lib/l10n/app_localizations_it.dart
+++ b/lib/l10n/app_localizations_it.dart
@@ -5465,6 +5465,33 @@ class AppLocalizationsIt extends AppLocalizations {
return '$showTitle: $_temp0';
}
+ @override
+ String lpSubscribedEpisodeAddedStart(String showTitle) {
+ return '$showTitle added to the top of your queue';
+ }
+
+ @override
+ String lpSubscribedEpisodeAddedSecond(String showTitle) {
+ return '$showTitle added 2nd in your queue';
+ }
+
+ @override
+ String lpSubscribedEpisodeAddedEnd(String showTitle) {
+ return '$showTitle added to the end of your queue';
+ }
+
+ @override
+ String get episodeListNewEpisodePosition => 'New episode position';
+
+ @override
+ String get episodeListPositionTop => 'Top of queue';
+
+ @override
+ String get episodeListPositionSecond => 'Second in queue';
+
+ @override
+ String get episodeListPositionEnd => 'End of queue';
+
@override
String lpQueueDownloadingItems(int count) {
String _temp0 = intl.Intl.pluralLogic(
diff --git a/lib/l10n/app_localizations_ja.dart b/lib/l10n/app_localizations_ja.dart
index 39dff29d..9ae02993 100644
--- a/lib/l10n/app_localizations_ja.dart
+++ b/lib/l10n/app_localizations_ja.dart
@@ -5465,6 +5465,33 @@ class AppLocalizationsJa extends AppLocalizations {
return '$showTitle: $_temp0';
}
+ @override
+ String lpSubscribedEpisodeAddedStart(String showTitle) {
+ return '$showTitle added to the top of your queue';
+ }
+
+ @override
+ String lpSubscribedEpisodeAddedSecond(String showTitle) {
+ return '$showTitle added 2nd in your queue';
+ }
+
+ @override
+ String lpSubscribedEpisodeAddedEnd(String showTitle) {
+ return '$showTitle added to the end of your queue';
+ }
+
+ @override
+ String get episodeListNewEpisodePosition => 'New episode position';
+
+ @override
+ String get episodeListPositionTop => 'Top of queue';
+
+ @override
+ String get episodeListPositionSecond => 'Second in queue';
+
+ @override
+ String get episodeListPositionEnd => 'End of queue';
+
@override
String lpQueueDownloadingItems(int count) {
String _temp0 = intl.Intl.pluralLogic(
diff --git a/lib/l10n/app_localizations_no.dart b/lib/l10n/app_localizations_no.dart
index b7bf29fc..44285b2a 100644
--- a/lib/l10n/app_localizations_no.dart
+++ b/lib/l10n/app_localizations_no.dart
@@ -5465,6 +5465,33 @@ class AppLocalizationsNo extends AppLocalizations {
return '$showTitle: $_temp0';
}
+ @override
+ String lpSubscribedEpisodeAddedStart(String showTitle) {
+ return '$showTitle added to the top of your queue';
+ }
+
+ @override
+ String lpSubscribedEpisodeAddedSecond(String showTitle) {
+ return '$showTitle added 2nd in your queue';
+ }
+
+ @override
+ String lpSubscribedEpisodeAddedEnd(String showTitle) {
+ return '$showTitle added to the end of your queue';
+ }
+
+ @override
+ String get episodeListNewEpisodePosition => 'New episode position';
+
+ @override
+ String get episodeListPositionTop => 'Top of queue';
+
+ @override
+ String get episodeListPositionSecond => 'Second in queue';
+
+ @override
+ String get episodeListPositionEnd => 'End of queue';
+
@override
String lpQueueDownloadingItems(int count) {
String _temp0 = intl.Intl.pluralLogic(
diff --git a/lib/l10n/app_localizations_pt.dart b/lib/l10n/app_localizations_pt.dart
index 09d84807..ba0036b3 100644
--- a/lib/l10n/app_localizations_pt.dart
+++ b/lib/l10n/app_localizations_pt.dart
@@ -5465,6 +5465,33 @@ class AppLocalizationsPt extends AppLocalizations {
return '$showTitle: $_temp0';
}
+ @override
+ String lpSubscribedEpisodeAddedStart(String showTitle) {
+ return '$showTitle added to the top of your queue';
+ }
+
+ @override
+ String lpSubscribedEpisodeAddedSecond(String showTitle) {
+ return '$showTitle added 2nd in your queue';
+ }
+
+ @override
+ String lpSubscribedEpisodeAddedEnd(String showTitle) {
+ return '$showTitle added to the end of your queue';
+ }
+
+ @override
+ String get episodeListNewEpisodePosition => 'New episode position';
+
+ @override
+ String get episodeListPositionTop => 'Top of queue';
+
+ @override
+ String get episodeListPositionSecond => 'Second in queue';
+
+ @override
+ String get episodeListPositionEnd => 'End of queue';
+
@override
String lpQueueDownloadingItems(int count) {
String _temp0 = intl.Intl.pluralLogic(
diff --git a/lib/l10n/app_localizations_ro.dart b/lib/l10n/app_localizations_ro.dart
index a9c8cd29..0be96cf7 100644
--- a/lib/l10n/app_localizations_ro.dart
+++ b/lib/l10n/app_localizations_ro.dart
@@ -5465,6 +5465,33 @@ class AppLocalizationsRo extends AppLocalizations {
return '$showTitle: $_temp0';
}
+ @override
+ String lpSubscribedEpisodeAddedStart(String showTitle) {
+ return '$showTitle added to the top of your queue';
+ }
+
+ @override
+ String lpSubscribedEpisodeAddedSecond(String showTitle) {
+ return '$showTitle added 2nd in your queue';
+ }
+
+ @override
+ String lpSubscribedEpisodeAddedEnd(String showTitle) {
+ return '$showTitle added to the end of your queue';
+ }
+
+ @override
+ String get episodeListNewEpisodePosition => 'New episode position';
+
+ @override
+ String get episodeListPositionTop => 'Top of queue';
+
+ @override
+ String get episodeListPositionSecond => 'Second in queue';
+
+ @override
+ String get episodeListPositionEnd => 'End of queue';
+
@override
String lpQueueDownloadingItems(int count) {
String _temp0 = intl.Intl.pluralLogic(
diff --git a/lib/l10n/app_localizations_ru.dart b/lib/l10n/app_localizations_ru.dart
index 873ec468..b431e583 100644
--- a/lib/l10n/app_localizations_ru.dart
+++ b/lib/l10n/app_localizations_ru.dart
@@ -5468,6 +5468,33 @@ class AppLocalizationsRu extends AppLocalizations {
return '$showTitle: $_temp0';
}
+ @override
+ String lpSubscribedEpisodeAddedStart(String showTitle) {
+ return '$showTitle added to the top of your queue';
+ }
+
+ @override
+ String lpSubscribedEpisodeAddedSecond(String showTitle) {
+ return '$showTitle added 2nd in your queue';
+ }
+
+ @override
+ String lpSubscribedEpisodeAddedEnd(String showTitle) {
+ return '$showTitle added to the end of your queue';
+ }
+
+ @override
+ String get episodeListNewEpisodePosition => 'New episode position';
+
+ @override
+ String get episodeListPositionTop => 'Top of queue';
+
+ @override
+ String get episodeListPositionSecond => 'Second in queue';
+
+ @override
+ String get episodeListPositionEnd => 'End of queue';
+
@override
String lpQueueDownloadingItems(int count) {
String _temp0 = intl.Intl.pluralLogic(
diff --git a/lib/l10n/app_localizations_zh.dart b/lib/l10n/app_localizations_zh.dart
index d4220ddf..bba18149 100644
--- a/lib/l10n/app_localizations_zh.dart
+++ b/lib/l10n/app_localizations_zh.dart
@@ -5390,6 +5390,33 @@ class AppLocalizationsZh extends AppLocalizations {
return '$showTitle: $_temp0';
}
+ @override
+ String lpSubscribedEpisodeAddedStart(String showTitle) {
+ return '$showTitle added to the top of your queue';
+ }
+
+ @override
+ String lpSubscribedEpisodeAddedSecond(String showTitle) {
+ return '$showTitle added 2nd in your queue';
+ }
+
+ @override
+ String lpSubscribedEpisodeAddedEnd(String showTitle) {
+ return '$showTitle added to the end of your queue';
+ }
+
+ @override
+ String get episodeListNewEpisodePosition => 'New episode position';
+
+ @override
+ String get episodeListPositionTop => 'Top of queue';
+
+ @override
+ String get episodeListPositionSecond => 'Second in queue';
+
+ @override
+ String get episodeListPositionEnd => 'End of queue';
+
@override
String lpQueueDownloadingItems(int count) {
String _temp0 = intl.Intl.pluralLogic(
diff --git a/lib/providers/_lp_core.dart b/lib/providers/_lp_core.dart
index 41eedcd2..d79d3a05 100644
--- a/lib/providers/_lp_core.dart
+++ b/lib/providers/_lp_core.dart
@@ -1891,11 +1891,37 @@ mixin _CoreMixin on ChangeNotifier, _StateMixin {
debugPrint('[Subscription] ${newEpisodes.length} new episode(s) for $itemId');
int queued = 0;
+ // Per-show choice of where the new episode lands in the absorbing queue.
+ final position = await PlayerSettings.getPodcastNewEpisodePosition(itemId);
+ // 'second' means the 2nd item the user actually sees. With merge on the
+ // queue is global, so that's index 1. With merge off the home view is
+ // filtered to this podcast's library, so insert after the first entry from
+ // the same library instead (otherwise an item from another library at
+ // index 0 would push this to visible-first). 'start'/'end' are the list
+ // extremes and read correctly in both modes, so they need no adjustment.
+ final merged = await PlayerSettings.getMergeAbsorbingLibraries();
+ final libId = item['libraryId'] as String?;
+
for (final epMap in newEpisodes) {
final epId = epMap['id'] as String;
final key = '$itemId-$epId';
- _absorbingIdsAdd(key, atFront: true);
+ switch (position) {
+ case 'end':
+ _absorbingIdsAdd(key, atFront: false);
+ break;
+ case 'second':
+ if (merged) {
+ _absorbingIdsAdd(key, atIndex: 1);
+ } else {
+ final firstSameLib = _absorbingBookIds.indexWhere(
+ (k) => _absorbingItemCache[k]?['libraryId'] == libId);
+ _absorbingIdsAdd(key, atIndex: firstSameLib >= 0 ? firstSameLib + 1 : 0);
+ }
+ break;
+ default:
+ _absorbingIdsAdd(key, atFront: true);
+ }
_absorbingItemCache[key] = {
'id': itemId,
'libraryId': item['libraryId'] as String?,
@@ -1974,9 +2000,26 @@ mixin _CoreMixin on ChangeNotifier, _StateMixin {
final media = cached['media'] as Map<String, dynamic>? ?? {};
final metadata = media['metadata'] as Map<String, dynamic>? ?? {};
final showTitle = metadata['title'] as String? ?? 'Podcast';
+ final position = await PlayerSettings.getPodcastNewEpisodePosition(podcastId);
final l = _l();
- _showRollingSnackBar(l?.lpSubscribedPodcastDownloading(showTitle, downloaded)
- ?? '$showTitle: $downloaded new episode${downloaded == 1 ? '' : 's'} downloading');
+ final String message;
+ switch (position) {
+ case 'end':
+ message = l?.lpSubscribedEpisodeAddedEnd(showTitle)
+ ?? '$showTitle added to the end of your queue';
+ break;
+ case 'second':
+ message = l?.lpSubscribedEpisodeAddedSecond(showTitle)
+ ?? '$showTitle added 2nd in your queue';
+ break;
+ default:
+ message = l?.lpSubscribedEpisodeAddedStart(showTitle)
+ ?? '$showTitle added to the top of your queue';
+ }
+ final ctx = rootNavigatorKey.currentContext;
+ if (ctx != null) {
+ showOverlayToast(ctx, message, icon: Icons.playlist_add_rounded);
+ }
}
}
@@ -2373,7 +2416,7 @@ mixin _CoreMixin on ChangeNotifier, _StateMixin {
// ── Absorbing helpers used by _CoreMixin ──
- void _absorbingIdsAdd(String key, {String? afterKey, bool atFront = true}) {
+ void _absorbingIdsAdd(String key, {String? afterKey, bool atFront = true, int? atIndex}) {
if (_absorbingBookIds.contains(key) && afterKey == null) return;
if (afterKey != null) {
@@ -2385,7 +2428,9 @@ mixin _CoreMixin on ChangeNotifier, _StateMixin {
}
}
if (_absorbingBookIds.contains(key)) return;
- if (atFront) {
+ if (atIndex != null) {
+ _absorbingBookIds.insert(atIndex.clamp(0, _absorbingBookIds.length), key);
+ } else if (atFront) {
_absorbingBookIds.insert(0, key);
} else {
_absorbingBookIds.add(key);
diff --git a/lib/providers/library_provider.dart b/lib/providers/library_provider.dart
index 795ca687..cddde334 100644
--- a/lib/providers/library_provider.dart
+++ b/lib/providers/library_provider.dart
@@ -21,6 +21,7 @@ import '../services/socket_service.dart';
import '../services/home_widget_service.dart';
import '../l10n/app_localizations.dart';
import '../main.dart' show scaffoldMessengerKey, rootNavigatorKey;
+import '../widgets/overlay_toast.dart';
part '_lp_state.dart';
part '_lp_core.dart';
diff --git a/lib/services/player_settings.dart b/lib/services/player_settings.dart
index 077c61e5..d36d2033 100644
--- a/lib/services/player_settings.dart
+++ b/lib/services/player_settings.dart
@@ -236,6 +236,19 @@ class PlayerSettings {
_notify();
}
+ /// Where a subscribed show's auto-downloaded new episode lands in the
+ /// absorbing queue: 'start' (top, default), 'second' (2nd), or 'end'. Per
+ /// show, stored under a raw key like the advance direction above.
+ static Future<String> getPodcastNewEpisodePosition(String showId) async {
+ final prefs = await SharedPreferences.getInstance();
+ return prefs.getString('podcast_new_ep_pos_$showId') ?? 'start';
+ }
+ static Future<void> setPodcastNewEpisodePosition(String showId, String value) async {
+ final prefs = await SharedPreferences.getInstance();
+ await prefs.setString('podcast_new_ep_pos_$showId', value);
+ _notify();
+ }
+
/// Active playlist ID for playlist queue mode. Null when no playlist is selected.
static Future<String?> getQueuePlaylistId() async {
final s = await ScopedPrefs.getString('queuePlaylistId');
diff --git a/lib/widgets/episode_list_sheet.dart b/lib/widgets/episode_list_sheet.dart
index 24549979..b62adfb8 100644
--- a/lib/widgets/episode_list_sheet.dart
+++ b/lib/widgets/episode_list_sheet.dart
@@ -57,6 +57,7 @@ class _EpisodeListSheetState extends State<EpisodeListSheet> {
bool _isDownloadingAll = false;
bool _autoDownloadEnabled = false;
bool _subscribed = false;
+ String _newEpisodePosition = 'start';
bool _newestFirst = true;
bool _hideFinished = false;
bool _selectMode = false;
@@ -97,6 +98,13 @@ class _EpisodeListSheetState extends State<EpisodeListSheet> {
_loadHideFinished();
_loadEpisodes();
_loadAutoDownloadState();
+ _loadNewEpisodePosition();
+ }
+
+ void _loadNewEpisodePosition() async {
+ if (_itemId.isEmpty) return;
+ final pos = await PlayerSettings.getPodcastNewEpisodePosition(_itemId);
+ if (mounted) setState(() => _newEpisodePosition = pos);
}
void _loadSortOrder() async {
@@ -456,6 +464,11 @@ class _EpisodeListSheetState extends State<EpisodeListSheet> {
}
}
}),
+ if (_itemId.isNotEmpty && _subscribed)
+ ActionPillData(
+ icon: Icons.low_priority_rounded,
+ label: l.episodeListNewEpisodePosition,
+ onTap: () { Navigator.pop(ctx); _showNewEpisodePositionPicker(); }),
ActionPillData(
icon: _hideFinished ? Icons.visibility_rounded : Icons.visibility_off_rounded,
label: _hideFinished ? l.episodeListShowFinishedEpisodes : l.episodeListHideFinishedEpisodes,
@@ -468,6 +481,55 @@ class _EpisodeListSheetState extends State<EpisodeListSheet> {
);
}
+ void _showNewEpisodePositionPicker() {
+ final l = AppLocalizations.of(context)!;
+ final cs = Theme.of(context).colorScheme;
+ final options = <String, String>{
+ 'start': l.episodeListPositionTop,
+ 'second': l.episodeListPositionSecond,
+ 'end': l.episodeListPositionEnd,
+ };
+ showModalBottomSheet(
+ context: context,
+ backgroundColor: Theme.of(context).bottomSheetTheme.backgroundColor,
+ shape: const RoundedRectangleBorder(
+ borderRadius: BorderRadius.vertical(top: Radius.circular(24)),
+ ),
+ builder: (ctx) => SafeArea(
+ child: Padding(
+ padding: const EdgeInsets.fromLTRB(8, 8, 8, 16),
+ child: Column(mainAxisSize: MainAxisSize.min, children: [
+ Center(child: Container(width: 40, height: 4, margin: const EdgeInsets.only(bottom: 8),
+ decoration: BoxDecoration(color: cs.onSurface.withValues(alpha: 0.24), borderRadius: BorderRadius.circular(2)))),
+ Padding(
+ padding: const EdgeInsets.fromLTRB(16, 8, 16, 12),
+ child: Align(
+ alignment: Alignment.centerLeft,
+ child: Text(l.episodeListNewEpisodePosition,
+ style: Theme.of(context).textTheme.titleMedium?.copyWith(fontWeight: FontWeight.w600)),
+ ),
+ ),
+ for (final entry in options.entries)
+ ListTile(
+ leading: Icon(
+ _newEpisodePosition == entry.key
+ ? Icons.radio_button_checked_rounded
+ : Icons.radio_button_unchecked_rounded,
+ color: _newEpisodePosition == entry.key ? cs.primary : cs.onSurfaceVariant,
+ ),
+ title: Text(entry.value),
+ onTap: () async {
+ Navigator.pop(ctx);
+ await PlayerSettings.setPodcastNewEpisodePosition(_itemId, entry.key);
+ if (mounted) setState(() => _newEpisodePosition = entry.key);
+ },
+ ),
+ ]),
+ ),
+ ),
+ );
+ }
+
String? get _coverUrl {
final auth = context.read<AuthProvider>();
return auth.apiService?.getCoverUrl(_itemId, width: 800);