mirror of
https://github.com/jellyfin/jellyfin-web
synced 2025-03-30 19:56:21 +00:00
Update ApiClient instance used by SyncPlay manager
This commit is contained in:
parent
7d880f07ce
commit
f0d483dee3
2 changed files with 15 additions and 5 deletions
|
@ -47,12 +47,8 @@ class Manager {
|
||||||
* @param {Object} apiClient The ApiClient.
|
* @param {Object} apiClient The ApiClient.
|
||||||
*/
|
*/
|
||||||
init(apiClient) {
|
init(apiClient) {
|
||||||
if (!apiClient) {
|
|
||||||
throw new Error('ApiClient is null!');
|
|
||||||
}
|
|
||||||
|
|
||||||
// Set ApiClient.
|
// Set ApiClient.
|
||||||
this.apiClient = apiClient;
|
this.updateApiClient(apiClient);
|
||||||
|
|
||||||
// Get default player wrapper.
|
// Get default player wrapper.
|
||||||
this.playerWrapper = this.playerFactory.getDefaultWrapper(this);
|
this.playerWrapper = this.playerFactory.getDefaultWrapper(this);
|
||||||
|
@ -73,6 +69,18 @@ class Manager {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update active ApiClient.
|
||||||
|
* @param {Object} apiClient The ApiClient.
|
||||||
|
*/
|
||||||
|
updateApiClient(apiClient) {
|
||||||
|
if (!apiClient) {
|
||||||
|
throw new Error('ApiClient is null!');
|
||||||
|
}
|
||||||
|
|
||||||
|
this.apiClient = apiClient;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the time sync core.
|
* Gets the time sync core.
|
||||||
* @returns {TimeSyncCore} The time sync core.
|
* @returns {TimeSyncCore} The time sync core.
|
||||||
|
|
|
@ -172,6 +172,8 @@ function initSyncPlay() {
|
||||||
|
|
||||||
// FIXME: Multiple apiClients?
|
// FIXME: Multiple apiClients?
|
||||||
Events.on(ServerConnections, 'apiclientcreated', (e, newApiClient) => SyncPlay.Manager.init(newApiClient));
|
Events.on(ServerConnections, 'apiclientcreated', (e, newApiClient) => SyncPlay.Manager.init(newApiClient));
|
||||||
|
Events.on(ServerConnections, 'localusersignedin', () => SyncPlay.Manager.updateApiClient(ServerConnections.currentApiClient()));
|
||||||
|
Events.on(ServerConnections, 'localusersignedout', () => SyncPlay.Manager.updateApiClient(ServerConnections.currentApiClient()));
|
||||||
}
|
}
|
||||||
|
|
||||||
async function onAppReady() {
|
async function onAppReady() {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue