From ee98fe0c9d5fc6c4ed901f0a4a18cf5f22f39f8f Mon Sep 17 00:00:00 2001 From: Jan Nowakowski Date: Tue, 17 Dec 2024 08:27:11 +0100 Subject: [PATCH] Chain on init Promise to resolve --- src/libs/Pusher/pusher.ts | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/libs/Pusher/pusher.ts b/src/libs/Pusher/pusher.ts index f18fcf5d1d95..8cdc13134015 100644 --- a/src/libs/Pusher/pusher.ts +++ b/src/libs/Pusher/pusher.ts @@ -95,7 +95,6 @@ function callSocketEventCallbacks(eventName: SocketEventName, data?: EventCallba function init(args: Args, params?: unknown): Promise { return new Promise((resolve) => { if (socket) { - resolveInitPromise(); resolve(); return; } @@ -135,7 +134,6 @@ function init(args: Args, params?: unknown): Promise { socket?.connection.bind('connected', () => { pusherSocketID = socket?.connection.socket_id ?? ''; callSocketEventCallbacks('connected'); - resolveInitPromise(); resolve(); }); @@ -146,7 +144,7 @@ function init(args: Args, params?: unknown): Promise { socket?.connection.bind('state_change', (states: States) => { callSocketEventCallbacks('state_change', states); }); - }); + }).then(resolveInitPromise); } /**