From 765c5c50f8121fe286839ff2bb4c8fde370d76af Mon Sep 17 00:00:00 2001 From: Diego Mello Date: Mon, 14 Feb 2022 16:23:13 -0300 Subject: [PATCH] Chore: Move some methods to SDK (#3736) --- app/lib/rocketchat/rocketchat.js | 11 +++++++---- app/lib/rocketchat/services/sdk.ts | 24 ++++++++++++++++++++++++ 2 files changed, 31 insertions(+), 4 deletions(-) diff --git a/app/lib/rocketchat/rocketchat.js b/app/lib/rocketchat/rocketchat.js index 2d3fd5654..cd5977f02 100644 --- a/app/lib/rocketchat/rocketchat.js +++ b/app/lib/rocketchat/rocketchat.js @@ -976,16 +976,19 @@ const RocketChat = { return `${server}/${roomType}/${channel.name}`; }, subscribe(...args) { - return this.sdk.subscribe(...args); + return sdk.subscribe(...args); + }, + subscribeRaw(...args) { + return sdk.subscribeRaw(...args); }, subscribeRoom(...args) { - return this.sdk.subscribeRoom(...args); + return sdk.subscribeRoom(...args); }, unsubscribe(subscription) { - return this.sdk.unsubscribe(subscription); + return sdk.unsubscribe(subscription); }, onStreamData(...args) { - return this.sdk.onStreamData(...args); + return sdk.onStreamData(...args); }, emitTyping(room, typing = true) { const { login, settings } = reduxStore.getState(); diff --git a/app/lib/rocketchat/services/sdk.ts b/app/lib/rocketchat/services/sdk.ts index 869657a29..44f151e59 100644 --- a/app/lib/rocketchat/services/sdk.ts +++ b/app/lib/rocketchat/services/sdk.ts @@ -27,6 +27,10 @@ class Sdk { return this.sdk; } + get current() { + return this.sdk; + } + /** * TODO: evaluate the need for assigning "null" to this.sdk * I'm returning "null" because we need to remove both instances of this.sdk here and on rocketchat.js @@ -141,6 +145,26 @@ class Sdk { }); return this.methodCall(method, ...parsedParams); } + + subscribe(...args: any[]) { + return this.sdk.subscribe(...args); + } + + subscribeRaw(...args: any[]) { + return this.sdk.subscribeRaw(...args); + } + + subscribeRoom(...args: any[]) { + return this.sdk.subscribeRoom(...args); + } + + unsubscribe(subscription: any[]) { + return this.sdk.unsubscribe(subscription); + } + + onStreamData(...args: any[]) { + return this.sdk.onStreamData(...args); + } } const sdk = new Sdk();