From e4677df320ed591fd95a76b91d220e9a77c7fc04 Mon Sep 17 00:00:00 2001 From: Niels van Velzen Date: Fri, 3 Apr 2026 17:39:39 +0200 Subject: [PATCH 1/2] Load device information lazily in connection manager --- .../jellyfin-apiclient/ServerConnections.js | 8 ++++---- .../jellyfin-apiclient/connectionManager.js | 18 ++++++++++-------- 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/src/lib/jellyfin-apiclient/ServerConnections.js b/src/lib/jellyfin-apiclient/ServerConnections.js index bae007970a..12864e2a7f 100644 --- a/src/lib/jellyfin-apiclient/ServerConnections.js +++ b/src/lib/jellyfin-apiclient/ServerConnections.js @@ -152,8 +152,8 @@ const capabilities = Dashboard.capabilities(appHost); export default new ServerConnections( credentialProvider, - appHost.appName(), - appHost.appVersion(), - appHost.deviceName(), - appHost.deviceId(), + () => appHost.appName(), + () => appHost.appVersion(), + () => appHost.deviceName(), + () => appHost.deviceId(), capabilities); diff --git a/src/lib/jellyfin-apiclient/connectionManager.js b/src/lib/jellyfin-apiclient/connectionManager.js index 898844b6fc..2789e9ddc2 100644 --- a/src/lib/jellyfin-apiclient/connectionManager.js +++ b/src/lib/jellyfin-apiclient/connectionManager.js @@ -63,13 +63,15 @@ export default class ConnectionManager { // Set the minimum version to match the SDK self._minServerVersion = MINIMUM_VERSION; - self.appVersion = () => appVersion; + self.appVersion = () => typeof appVersion === 'function' ? appVersion() : appVersion; - self.appName = () => appName; + self.appName = () => typeof appName === 'function' ? appName() : appName; self.capabilities = () => capabilities; - self.deviceId = () => deviceId; + self.deviceName = () => typeof deviceName === 'function' ? deviceName() : deviceName; + + self.deviceId = () => typeof deviceId === 'function' ? deviceId() : deviceId; self.credentialProvider = () => credentialProvider; @@ -137,7 +139,7 @@ export default class ConnectionManager { let apiClient = self.getApiClient(server.Id); if (!apiClient) { - apiClient = new ApiClient(serverUrl, appName, appVersion, deviceName, deviceId); + apiClient = new ApiClient(serverUrl, self.appName(), self.appVersion(), self.deviceName(), self.deviceId()); self._apiClients.push(apiClient); @@ -232,12 +234,12 @@ export default class ConnectionManager { headers: { [AUTHORIZATION_HEADER]: getAuthorizationHeader( { - name: appName, - version: appVersion + name: self.appName(), + version: self.appVersion() }, { - id: deviceId, - name: deviceName + id: self.deviceId(), + name: self.deviceName() }, server.AccessToken ) From de26159fabe790048b83c63a7d78ca794f54766f Mon Sep 17 00:00:00 2001 From: Niels van Velzen Date: Fri, 3 Apr 2026 17:39:57 +0200 Subject: [PATCH 2/2] Initialize server notifications after apphost init --- src/index.jsx | 5 ++++- src/scripts/serverNotifications.js | 10 ++++++---- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/index.jsx b/src/index.jsx index 6a2a3fbcbd..a5c4e76232 100644 --- a/src/index.jsx +++ b/src/index.jsx @@ -22,6 +22,7 @@ import { getPlugins } from './scripts/settings/webSettings'; import taskButton from './scripts/taskbutton'; import { pageClassOn, serverAddress } from './utils/dashboard'; import Events from './utils/events'; +import { initializeServerConnections } from './scripts/serverNotifications'; import RootApp from './RootApp'; @@ -37,7 +38,6 @@ import './components/themeMediaPlayer'; import './scripts/autoThemes'; import './scripts/mouseManager'; import './scripts/screensavermanager'; -import './scripts/serverNotifications'; // Import site styles import './styles/site.scss'; @@ -110,6 +110,9 @@ build: ${__JF_BUILD_VERSION__}`); Events.on(apiClient, 'requestfail', appRouter.onRequestFail); }); + // Start server notifications + initializeServerConnections(); + // Render the app await renderApp(); diff --git a/src/scripts/serverNotifications.js b/src/scripts/serverNotifications.js index 0f9353dcf4..81b621398f 100644 --- a/src/scripts/serverNotifications.js +++ b/src/scripts/serverNotifications.js @@ -201,10 +201,12 @@ function bindEvents(apiClient) { Events.on(apiClient, 'message', onMessageReceived); } -ServerConnections.getApiClients().forEach(bindEvents); -Events.on(ServerConnections, 'apiclientcreated', function (e, newApiClient) { - bindEvents(newApiClient); -}); +export function initializeServerConnections() { + ServerConnections.getApiClients().forEach(bindEvents); + Events.on(ServerConnections, 'apiclientcreated', function (e, newApiClient) { + bindEvents(newApiClient); + }); +} window.ServerNotifications = serverNotifications;