refactor(watch): shared point-of-use resolution across consumers

Adds context.withFreshWatchState/readFreshWatchState and sweeps the
remaining session-critical readers: context menu actions, folder tree
rows, discover hero, and TV spotlight minutes-left.
This commit is contained in:
edde746
2026-06-10 05:38:33 +02:00
parent 903b8eced8
commit 9b48f26463
10 changed files with 63 additions and 52 deletions
@@ -5,6 +5,7 @@ import 'package:flutter/material.dart';
import 'package:plezy/widgets/app_icon.dart';
import 'package:material_symbols_icons/symbols.dart';
import '../../focus/focusable_button.dart';
import '../../providers/watch_state_store.dart';
import '../../focus/focusable_wrapper.dart';
import '../../media/media_item.dart';
import '../../media/media_item_types.dart';
@@ -72,6 +73,8 @@ class FolderTreeItem extends StatelessWidget {
return item.displayTitle;
}
MediaItem _effectiveItem(BuildContext context) => context.withFreshWatchState(item);
String? _dedupeSubtitle(String? subtitle) {
final value = subtitle?.trim();
if (value == null || value.isEmpty || value == _rowTitle()) return null;
@@ -271,6 +274,8 @@ class FolderTreeItem extends StatelessWidget {
}
Widget _buildWatchOverlay(BuildContext context, bool showUnwatchedCount) {
// Shadows the field with the session-fresh view; everything below reads it.
final item = _effectiveItem(context);
final hasActiveProgress = item.hasActiveProgress;
return Stack(