Skip to content

Commit

Permalink
Fix default auto cast
Browse files Browse the repository at this point in the history
  • Loading branch information
viown committed Sep 9, 2024
1 parent 6cae5c2 commit d08dcec
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 14 deletions.
4 changes: 2 additions & 2 deletions src/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -69,15 +69,15 @@ function init() {
window.Events = Events;
window.TaskButton = taskButton;

initializeAutoCast();

serverAddress().then(server => {
if (server) {
ServerConnections.initApiClient(server);
}
}).then(() => {
console.debug('initAfterDependencies promises resolved');

initializeAutoCast(ServerConnections.currentApiClient());

loadCoreDictionary().then(function () {
onGlobalizeInit();
});
Expand Down
23 changes: 11 additions & 12 deletions src/scripts/autocast.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import ServerConnections from 'components/ServerConnections';
import { playbackManager } from '../components/playback/playbackmanager';
import Events from '../utils/events.ts';

Expand Down Expand Up @@ -43,16 +44,14 @@ function onOpen() {
});
}

export function initialize(apiClient) {
if (apiClient) {
if (apiClient.isWebSocketOpen()) {
console.debug('[autoCast] connection ready');
onOpen();
} else {
console.debug('[autoCast] initializing connection listener');
Events.on(apiClient, 'websocketopen', onOpen);
}
} else {
console.warn('[autoCast] cannot initialize missing apiClient');
}
export function initialize() {
ServerConnections.getApiClients().forEach(apiClient => {
Events.off(apiClient, 'websocketopen', onOpen);
Events.on(apiClient, 'websocketopen', onOpen);
});

Events.on(ServerConnections, 'apiclientcreated', (e, apiClient) => {
Events.off(apiClient, 'websocketopen', onOpen);
Events.on(apiClient, 'websocketopen', onOpen);
});
}

0 comments on commit d08dcec

Please sign in to comment.