From d589168e73c065d232cc6131072942b3bea15f38 Mon Sep 17 00:00:00 2001 From: SrGooglo Date: Thu, 15 May 2025 14:09:31 +0000 Subject: [PATCH] Fix websocket restoration --- packages/app/src/App.jsx | 4 ++++ packages/app/src/cores/api/api.core.js | 14 +++++--------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/packages/app/src/App.jsx b/packages/app/src/App.jsx index 9ade66ce..68462acc 100755 --- a/packages/app/src/App.jsx +++ b/packages/app/src/App.jsx @@ -40,11 +40,15 @@ class ComtyApp extends React.Component { await this.auth.flush() await this.initialization() + app.cores.api.reset() + app.navigation.goMain() }, onLogout: async () => { await this.auth.flush() + app.cores.api.reset() + app.navigation.goAuth() }, onInvalidSession: async (error) => { diff --git a/packages/app/src/cores/api/api.core.js b/packages/app/src/cores/api/api.core.js index 57dd287c..ae73ade9 100755 --- a/packages/app/src/cores/api/api.core.js +++ b/packages/app/src/cores/api/api.core.js @@ -24,6 +24,7 @@ export default class APICore extends Core { listenEvent: this.listenEvent.bind(this), unlistenEvent: this.unlistenEvent.bind(this), emitEvent: this.emitEvent.bind(this), + reset: this.reset.bind(this), measurePing: measurePing, useRequest: useRequest, } @@ -84,6 +85,10 @@ export default class APICore extends Core { return this.client.ws.sockets.get(instance).off(key, handler) } + async reset() { + this.client.ws.connectAll() + } + async onInitialize() { this.client = await createClient({ eventBus: app.eventBus, @@ -93,15 +98,6 @@ export default class APICore extends Core { }, }) - // handle auth events - this.client.eventBus.on("auth:login_success", () => { - this.client.ws.connectAll() - }) - - this.client.eventBus.on("auth:logout_success", () => { - this.client.ws.connectAll() - }) - // make a basic request to check if the API is available await this.client .baseRequest({