fix(propagation): scope events by server

This commit is contained in:
edde746
2026-02-06 09:58:57 +01:00
parent f6aa8e51e0
commit bbee74ef9d
9 changed files with 152 additions and 2 deletions
+33
View File
@@ -76,6 +76,9 @@ class _MediaDetailScreenState extends State<MediaDetailScreen> with WatchStateAw
// GlobalKeys for season cards to access their context menu
final Map<int, GlobalKey<MediaCardState>> _seasonCardKeys = {};
String _toGlobalKey(String ratingKey, {String? serverId}) =>
'${serverId ?? widget.metadata.serverId ?? ''}:$ratingKey';
// WatchStateAware: watch the show/movie and all season ratingKeys
@override
Set<String>? get watchedRatingKeys {
@@ -86,6 +89,21 @@ class _MediaDetailScreenState extends State<MediaDetailScreen> with WatchStateAw
return keys;
}
@override
String? get watchStateServerId => widget.metadata.serverId;
@override
Set<String>? get watchedGlobalKeys {
final serverId = widget.metadata.serverId;
if (serverId == null) return null;
final keys = <String>{_toGlobalKey(widget.metadata.ratingKey, serverId: serverId)};
for (final season in _seasons) {
keys.add(_toGlobalKey(season.ratingKey, serverId: season.serverId ?? serverId));
}
return keys;
}
@override
void onWatchStateChanged(WatchStateEvent event) {
// Lightweight refresh - no loader, preserves scroll position
@@ -103,6 +121,21 @@ class _MediaDetailScreenState extends State<MediaDetailScreen> with WatchStateAw
return keys;
}
@override
String? get deletionServerId => widget.metadata.serverId;
@override
Set<String>? get deletionGlobalKeys {
final serverId = widget.metadata.serverId;
if (serverId == null) return null;
final keys = <String>{_toGlobalKey(widget.metadata.ratingKey, serverId: serverId)};
for (final season in _seasons) {
keys.add(_toGlobalKey(season.ratingKey, serverId: season.serverId ?? serverId));
}
return keys;
}
@override
void onDeletionEvent(DeletionEvent event) {
if (widget.isOffline) return;