From 5396e3c95c1f671ca6df288fbed983e69d20aba7 Mon Sep 17 00:00:00 2001 From: viown <48097677+viown@users.noreply.github.com> Date: Sun, 8 Sep 2024 13:53:29 +0300 Subject: [PATCH 1/2] fix merge conflict --- src/index.jsx | 2 +- src/scripts/autocast.js | 23 +++++++++++------------ 2 files changed, 12 insertions(+), 13 deletions(-) diff --git a/src/index.jsx b/src/index.jsx index 0e1ff4f668..dac6f72e8b 100644 --- a/src/index.jsx +++ b/src/index.jsx @@ -74,7 +74,7 @@ build: ${__JF_BUILD_VERSION__}`); } // Initialize automatic (default) cast target - initializeAutoCast(ServerConnections.currentApiClient()); + initializeAutoCast(); // Load the translation dictionary await loadCoreDictionary(); diff --git a/src/scripts/autocast.js b/src/scripts/autocast.js index 16f5865723..2c70e42c6f 100644 --- a/src/scripts/autocast.js +++ b/src/scripts/autocast.js @@ -1,3 +1,4 @@ +import ServerConnections from 'components/ServerConnections'; import { playbackManager } from '../components/playback/playbackmanager'; import Events from '../utils/events.ts'; @@ -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); + }); } From 7b1535073bdcc4188ef5c1ed687fbff3b8c0350a Mon Sep 17 00:00:00 2001 From: viown <48097677+viown@users.noreply.github.com> Date: Sun, 8 Sep 2024 15:24:20 +0300 Subject: [PATCH 2/2] add log message --- src/scripts/autocast.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/scripts/autocast.js b/src/scripts/autocast.js index 2c70e42c6f..65d7b19de7 100644 --- a/src/scripts/autocast.js +++ b/src/scripts/autocast.js @@ -45,6 +45,7 @@ function onOpen() { } export function initialize() { + console.debug('[autoCast] initializing connection listener'); ServerConnections.getApiClients().forEach(apiClient => { Events.off(apiClient, 'websocketopen', onOpen); Events.on(apiClient, 'websocketopen', onOpen);