From a4914d73cbb53231703068ef4f590adeacd6d5ee Mon Sep 17 00:00:00 2001 From: Djorkaeff Alexandre Date: Mon, 18 May 2020 14:55:53 -0300 Subject: [PATCH] [FIX] Sometimes SDK is null when try to connect (#2131) Co-authored-by: Diego Mello --- app/lib/rocketchat.js | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/app/lib/rocketchat.js b/app/lib/rocketchat.js index ddf562cc1..ecd7ae939 100644 --- a/app/lib/rocketchat.js +++ b/app/lib/rocketchat.js @@ -225,13 +225,12 @@ const RocketChat = { .catch((err) => { console.log('connect error', err); - const { server: currentServer } = reduxStore.getState().server; - if (server === currentServer) { - // when `connect` raises an error, we try again in 10 seconds - this.connectTimeout = setTimeout(() => { + // when `connect` raises an error, we try again in 10 seconds + this.connectTimeout = setTimeout(() => { + if (this.sdk?.client?.host === server) { sdkConnect(); - }, 10000); - } + } + }, 10000); }); sdkConnect();