From 8a65c78999681d98a09e7a60a1095301f6b8461b Mon Sep 17 00:00:00 2001 From: edde746 <86283021+edde746@users.noreply.github.com> Date: Fri, 12 Jun 2026 17:12:25 +0200 Subject: [PATCH] fix(plex): retry related hubs and skip unchanged threshold mirror --- lib/services/plex_client.dart | 30 +++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/lib/services/plex_client.dart b/lib/services/plex_client.dart index 7f81fa93..794396a9 100644 --- a/lib/services/plex_client.dart +++ b/lib/services/plex_client.dart @@ -1691,13 +1691,15 @@ class PlexClient _serverPrefs = _parseSettingsMap(response); // Mirror the watched threshold to settings: offline paths resolve it // synchronously with no client bound — see - // OfflineWatchSyncService.getWatchedThreshold. - unawaited( - SettingsService.instanceOrNull?.write( - SettingsService.watchedThresholdPref(ServerId(serverId)), - watchedThresholdPercent, - ), - ); + // OfflineWatchSyncService.getWatchedThreshold. Skipped when unchanged + // (this runs on every connect). + final settings = SettingsService.instanceOrNull; + if (settings != null) { + final pref = SettingsService.watchedThresholdPref(ServerId(serverId)); + if (settings.read(pref) != watchedThresholdPercent) { + unawaited(settings.write(pref, watchedThresholdPercent)); + } + } } catch (e) { appLogger.d('Failed to fetch server prefs: $e'); } @@ -1921,10 +1923,16 @@ class PlexClient /// Get related hubs for a specific metadata item (collections, similar, "more from" director/actor) Future> _getRelatedHubs(String ratingKey, {int count = 10}) async { try { - final response = await _getWithFailover( - '/hubs/metadata/$ratingKey/related', - queryParameters: {'count': count}, - allowEndpointFailover: false, + final response = await retryTransientMediaServerCall( + operation: 'Plex related hubs', + attemptTimeouts: MediaServerTimeouts.libraryHubAttemptTimeouts, + call: (timeout, abort) => _getWithFailover( + '/hubs/metadata/$ratingKey/related', + queryParameters: {'count': count}, + timeout: timeout, + abort: abort, + allowEndpointFailover: false, + ), ); final sid = serverId; final sname = serverName;