From d6ce877a0d75b9808417d0ba336a3e0b7a7233f8 Mon Sep 17 00:00:00 2001 From: Gerzon Z Date: Tue, 8 Mar 2022 11:41:00 -0400 Subject: [PATCH] fix: logout being `undefined` --- app/lib/methods/logout.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/app/lib/methods/logout.ts b/app/lib/methods/logout.ts index 0e53ed123..e9e3daebe 100644 --- a/app/lib/methods/logout.ts +++ b/app/lib/methods/logout.ts @@ -12,6 +12,7 @@ import log from '../../utils/log'; import { E2E_PRIVATE_KEY, E2E_PUBLIC_KEY, E2E_RANDOM_PASSWORD_KEY } from '../encryption/constants'; import UserPreferences from '../userPreferences'; import { ICertificate, IRocketChat } from '../../definitions'; +import sdk from '../rocketchat/services/sdk'; async function removeServerKeys({ server, userId }: { server: string; userId?: string | null }) { await UserPreferences.removeItem(`${RocketChat.TOKEN_KEY}-${server}`); @@ -116,13 +117,13 @@ export default async function logout(this: IRocketChat, { server }: { server: st try { // RC 0.60.0 - await this.sdk.logout(); + await sdk.current.logout(); } catch (e) { log(e); } - if (this.sdk) { - this.sdk = null; + if (sdk.current) { + sdk.disconnect(); } await removeServerData({ server });