mirror of
https://github.com/jellyfin/jellyfin-web
synced 2025-03-30 19:56:21 +00:00
Backport pull request #5898 from jellyfin-web/release-10.9.z
Fix autoCast race condition
Original-merge: 7f575d724e
Merged-by: thornbill <thornbill@users.noreply.github.com>
Backported-by: thornbill <thornbill@users.noreply.github.com>
This commit is contained in:
parent
75d78a96b8
commit
37fbfb3772
4 changed files with 26 additions and 39 deletions
|
@ -1,14 +1,7 @@
|
|||
import { playbackManager } from '../components/playback/playbackmanager';
|
||||
import ServerConnections from '../components/ServerConnections';
|
||||
import Events from '../utils/events.ts';
|
||||
|
||||
export function supported() {
|
||||
return typeof(Storage) !== 'undefined';
|
||||
}
|
||||
|
||||
export function enable(enabled) {
|
||||
if (!supported()) return;
|
||||
|
||||
if (enabled) {
|
||||
const currentPlayerInfo = playbackManager.getPlayerInfo();
|
||||
|
||||
|
@ -21,8 +14,6 @@ export function enable(enabled) {
|
|||
}
|
||||
|
||||
export function isEnabled() {
|
||||
if (!supported()) return false;
|
||||
|
||||
const playerId = localStorage.getItem('autocastPlayerId');
|
||||
const currentPlayerInfo = playbackManager.getPlayerInfo();
|
||||
|
||||
|
@ -42,12 +33,10 @@ function onOpen() {
|
|||
});
|
||||
}
|
||||
|
||||
try {
|
||||
const apiClient = ServerConnections.currentApiClient();
|
||||
|
||||
if (apiClient && supported()) {
|
||||
export function initialize(apiClient) {
|
||||
if (apiClient) {
|
||||
Events.on(apiClient, 'websocketopen', onOpen);
|
||||
} else {
|
||||
console.warn('[autoCast] cannot initialize missing apiClient');
|
||||
}
|
||||
} catch (ex) {
|
||||
console.warn('Could not get current apiClient', ex);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue