fix: notify season screen when download is deleted

This commit is contained in:
edde746
2026-02-14 18:37:28 +01:00
parent 86a989a2f2
commit 6f027f1015
3 changed files with 12 additions and 1 deletions
+3
View File
@@ -102,6 +102,9 @@ class _SeasonDetailScreenState extends State<SeasonDetailScreen>
@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) {
+7 -1
View File
@@ -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<DeletionEvent> {
}
/// 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<DeletionEvent> {
parentChain: _buildParentChain(metadata),
mediaType: metadata.type,
leafCount: metadata.leafCount ?? 1,
isDownloadOnly: isDownloadOnly,
),
);
}
+2
View File
@@ -1063,6 +1063,8 @@ class MediaContextMenuState extends State<MediaContextMenu> {
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);
}