diff --git a/lib/screens/season_detail_screen.dart b/lib/screens/season_detail_screen.dart index b1ae47d4..1985aebc 100644 --- a/lib/screens/season_detail_screen.dart +++ b/lib/screens/season_detail_screen.dart @@ -102,6 +102,9 @@ class _SeasonDetailScreenState extends State @override void onDeletionEvent(DeletionEvent event) { + // Download-only deletions should only remove items when viewing offline content + if (event.isDownloadOnly && !widget.isOffline) return; + // If we have an episode that matches the rating key exactly, then remove it from our list final index = _episodes.indexWhere((e) => e.ratingKey == event.ratingKey); if (index != -1) { diff --git a/lib/utils/deletion_notifier.dart b/lib/utils/deletion_notifier.dart index 2b38c6f6..d68a7672 100644 --- a/lib/utils/deletion_notifier.dart +++ b/lib/utils/deletion_notifier.dart @@ -31,12 +31,17 @@ class DeletionEvent with HierarchicalEventMixin { /// For an episode: 1. For a season: its episode count. For a show: its total episode count. final int leafCount; + /// True if only the local download was deleted (not the server-side media). + /// Screens should only remove items for download deletions when in offline mode. + final bool isDownloadOnly; + DeletionEvent({ required this.ratingKey, required this.serverId, required this.parentChain, required this.mediaType, this.leafCount = 1, + this.isDownloadOnly = false, }) : globalKey = '$serverId:$ratingKey'; @override @@ -68,7 +73,7 @@ class DeletionNotifier extends BaseNotifier { } /// Helper to emit a deletion event from metadata - void notifyDeleted({required PlexMetadata metadata}) { + void notifyDeleted({required PlexMetadata metadata, bool isDownloadOnly = false}) { notify( DeletionEvent( ratingKey: metadata.ratingKey, @@ -76,6 +81,7 @@ class DeletionNotifier extends BaseNotifier { parentChain: _buildParentChain(metadata), mediaType: metadata.type, leafCount: metadata.leafCount ?? 1, + isDownloadOnly: isDownloadOnly, ), ); } diff --git a/lib/widgets/media_context_menu.dart b/lib/widgets/media_context_menu.dart index 9fc2bcaf..3cd50b61 100644 --- a/lib/widgets/media_context_menu.dart +++ b/lib/widgets/media_context_menu.dart @@ -1063,6 +1063,8 @@ class MediaContextMenuState extends State { if (context.mounted) { showSuccessSnackBar(context, t.downloads.downloadDeleted); + // Notify DeletionAware screens (e.g. offline season detail) + DeletionNotifier().notifyDeleted(metadata: metadata, isDownloadOnly: true); // Refresh the view if needed widget.onRefresh?.call(metadata.ratingKey); }