From 48c9dcae1bbbbfbdfea7fd11e7345e6e5c319002 Mon Sep 17 00:00:00 2001 From: edde746 <86283021+edde746@users.noreply.github.com> Date: Sat, 28 Feb 2026 06:17:53 +0100 Subject: [PATCH] fix: apply hide spoilers setting to hero section close #588 --- lib/screens/discover_screen.dart | 21 ++++++++++++++++++++- lib/utils/content_utils.dart | 6 ++++-- 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/lib/screens/discover_screen.dart b/lib/screens/discover_screen.dart index e0ca4882..c1ad2a62 100644 --- a/lib/screens/discover_screen.dart +++ b/lib/screens/discover_screen.dart @@ -1283,6 +1283,10 @@ class _DiscoverScreenState extends State // Determine content type label for chip final contentTypeLabel = heroItem.isMovie ? t.discover.movie : t.discover.tvShow; + // Spoiler protection + final hideSpoilers = context.watch().hideSpoilers; + final shouldHideSpoiler = hideSpoilers && heroItem.shouldHideSpoiler; + // Build semantic label for hero item final heroLabel = isEpisode ? "${heroItem.grandparentTitle}, ${heroItem.title}" : heroItem.title; @@ -1492,7 +1496,7 @@ class _DiscoverScreenState extends State if (!isLargeScreen) ...[const SizedBox(height: 20), _buildSmartPlayButton(heroItem)], // Summary with episode info (Apple TV style) - if (heroItem.summary != null) ...[ + if (heroItem.summary != null && !shouldHideSpoiler) ...[ const SizedBox(height: 12), RichText( maxLines: 2, @@ -1523,6 +1527,21 @@ class _DiscoverScreenState extends State ], ), ), + ] else if (shouldHideSpoiler && isEpisode && heroItem.parentIndex != null && heroItem.index != null) ...[ + const SizedBox(height: 12), + Text( + 'S${heroItem.parentIndex}, E${heroItem.index}: ${heroItem.title}', + maxLines: 2, + overflow: TextOverflow.ellipsis, + textAlign: isLargeScreen ? TextAlign.left : TextAlign.center, + style: TextStyle( + color: isLargeScreen + ? Colors.white.withValues(alpha: 0.7) + : Theme.of(context).colorScheme.onSurface.withValues(alpha: 0.7), + fontSize: 14, + height: 1.4, + ), + ), ], // On large screens: show button after summary diff --git a/lib/utils/content_utils.dart b/lib/utils/content_utils.dart index a17b5481..b5d8021b 100644 --- a/lib/utils/content_utils.dart +++ b/lib/utils/content_utils.dart @@ -102,11 +102,13 @@ extension PlexMetadataType on PlexMetadata { bool get isVideoContent => ContentTypes.videoTypes.contains(_lowerType); /// Whether this episode should have spoiler protection applied. - /// True when the item is an unwatched episode with no active progress. + /// True when the item is an unwatched episode watched less than 50%. bool get shouldHideSpoiler { if (!isEpisode) return false; if (isWatched) return false; - if (viewOffset != null && viewOffset! > 0) return false; + if (viewOffset != null && viewOffset! > 0 && duration != null && duration! > 0) { + return viewOffset! / duration! < 0.5; + } return true; } }