mirror of
https://github.com/jellyfin/jellyfin-web.git
synced 2026-09-03 03:50:02 +03:00
Merge pull request #7796 from nielsvanvelzen/eager-api-init
Load device information lazily in connection manager
This commit is contained in:
+4
-1
@@ -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();
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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
|
||||
)
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user