Skip to content

A cross platform Audiobookshelf client for Android and iOS

Dart

Fix podcast episode detail sheet from discover page

Nathan Poulsonb50f01fa5bf1
diff --git a/lib/widgets/book_card.dart b/lib/widgets/book_card.dart
index 7ef78a77..0ed57913 100644
--- a/lib/widgets/book_card.dart
+++ b/lib/widgets/book_card.dart
@@ -52,7 +52,12 @@ class BookCard extends StatelessWidget {
if (itemId == null) return;
final lib = context.read<LibraryProvider>();
if (lib.isPodcastLibrary) {
- EpisodeListSheet.show(context, item);
+ final episode = item['recentEpisode'] as Map<String, dynamic>?;
+ if (episode != null) {
+ EpisodeDetailSheet.show(context, item, episode);
+ } else {
+ EpisodeListSheet.show(context, item);
+ }
} else {
showBookDetailSheet(context, itemId);
}
diff --git a/lib/widgets/episode_list_sheet.dart b/lib/widgets/episode_list_sheet.dart
index 7658aab6..99a07226 100644
--- a/lib/widgets/episode_list_sheet.dart
+++ b/lib/widgets/episode_list_sheet.dart
@@ -487,7 +487,13 @@ class _EpisodeDetailSheetState extends State<EpisodeDetailSheet> {
String get _episodeTitle => widget.episode['title'] as String? ?? 'Episode';
String get _episodeId => widget.episode['id'] as String? ?? '';
- double get _duration => (widget.episode['duration'] as num?)?.toDouble() ?? 0;
+ double get _duration {
+ final d = (widget.episode['duration'] as num?)?.toDouble() ?? 0;
+ if (d > 0) return d;
+ // recentEpisode from ABS personalized sections often omits top-level duration
+ final af = widget.episode['audioFile'] as Map<String, dynamic>?;
+ return (af?['duration'] as num?)?.toDouble() ?? 0;
+ }
int get _publishedAt => (widget.episode['publishedAt'] as num?)?.toInt() ?? 0;
String? get _episodeNumber => widget.episode['episode'] as String?;
String? get _season => widget.episode['season'] as String?;