fix: eliminate duplicate API requests on startup

- Skip redundant notifyListeners in HiddenLibrariesProvider init when
  set is empty (empty→empty is a no-op for consumers)
- Track last-seen hidden keys in DiscoverScreen to avoid reloading
  content when the listener fires without an actual change
- Track previous online server set in MultiServerProvider; only re-check
  DVR availability when a new server comes online
- Remove dead content-loading pipeline from libraries_screen (sorts,
  pagination, filters, items) that was never rendered
- Move /media/providers fetch into PlexClient.create() init, replacing
  lazy EPG cache and providing libraries including shared items
This commit is contained in:
edde746
2026-03-15 18:23:32 +01:00
parent a5629c54f6
commit 59b3e6ce81
7 changed files with 167 additions and 235 deletions
+6 -13
View File
@@ -130,21 +130,14 @@ class _LiveTvScreenState extends State<LiveTvScreen>
'Live TV DVRs: ${liveTvServers.map((s) => '${s.serverId}/${s.dvrKey} lineup=${s.lineup}').join(', ')}',
);
// Build a set of enabled channel keys per server from DVR mappings
// Build a set of enabled channel keys per server from cached DVR data
final enabledKeysByServer = <String, Set<String>>{};
final queriedServers = <String>{};
final processedServers = <String>{};
for (final serverInfo in liveTvServers) {
if (!queriedServers.add(serverInfo.serverId)) continue;
try {
final client = multiServer.getClientForServer(serverInfo.serverId);
if (client == null) continue;
final dvrs = await client.getDvrs();
final enabledKeys = _extractEnabledChannelKeys(dvrs);
if (enabledKeys != null) {
enabledKeysByServer[serverInfo.serverId] = enabledKeys;
}
} catch (e) {
appLogger.e('Failed to load DVR mappings for server ${serverInfo.serverId}', error: e);
if (!processedServers.add(serverInfo.serverId)) continue;
final enabledKeys = _extractEnabledChannelKeys(serverInfo.dvrs);
if (enabledKeys != null) {
enabledKeysByServer[serverInfo.serverId] = enabledKeys;
}
}