From 1aab65ef929444ea3b9aa789bc0910fca2424644 Mon Sep 17 00:00:00 2001 From: Gleidson Daniel Silva Date: Tue, 15 Mar 2022 16:53:24 -0300 Subject: [PATCH] Chore: Migrate REST API - readThreads to Typescript (#3866) * chore: migrate readThreads to typescript * fix imports --- app/lib/rocketchat/rocketchat.js | 8 ------ app/lib/rocketchat/services/restApi.ts | 34 +++++++++++++++++--------- 2 files changed, 22 insertions(+), 20 deletions(-) diff --git a/app/lib/rocketchat/rocketchat.js b/app/lib/rocketchat/rocketchat.js index 9857b771..eab89d83 100644 --- a/app/lib/rocketchat/rocketchat.js +++ b/app/lib/rocketchat/rocketchat.js @@ -434,14 +434,6 @@ const RocketChat = { getLoginServices, determineAuthType, roomTypeToApiType, - readThreads(tmid) { - const serverVersion = reduxStore.getState().server.version; - if (compareServerVersion(serverVersion, 'greaterThanOrEqualTo', '3.4.0')) { - // RC 3.4.0 - return this.methodCallWrapper('readThreads', tmid); - } - return Promise.resolve(); - }, _setUser(ddpMessage) { this.activeUsers = this.activeUsers || {}; const { user } = reduxStore.getState().login; diff --git a/app/lib/rocketchat/services/restApi.ts b/app/lib/rocketchat/services/restApi.ts index 0f80f9c3..27b3baef 100644 --- a/app/lib/rocketchat/services/restApi.ts +++ b/app/lib/rocketchat/services/restApi.ts @@ -1,20 +1,21 @@ -import sdk from './sdk'; -import { TEAM_TYPE } from '../../../definitions/ITeam'; -import roomTypeToApiType, { RoomTypes } from '../methods/roomTypeToApiType'; import { - SubscriptionType, - INotificationPreferences, - IRoomNotifications, - TRocketChat, IMessage, + INotificationPreferences, + IPreviewItem, IRoom, - IPreviewItem + IRoomNotifications, + SubscriptionType, + TRocketChat } from '../../../definitions'; -import { ISpotlight } from '../../../definitions/ISpotlight'; -import { IAvatarSuggestion, IParams } from '../../../definitions/IProfileViewInterfaces'; -import { Encryption } from '../../encryption'; import { TParams } from '../../../definitions/ILivechatEditView'; -import { store as reduxStore } from '../../auxStore'; +import { IAvatarSuggestion, IParams } from '../../../definitions/IProfileViewInterfaces'; +import { ISpotlight } from '../../../definitions/ISpotlight'; +import { TEAM_TYPE } from '../../../definitions/ITeam'; +import { store as reduxStore, store } from '../../auxStore'; +import { Encryption } from '../../encryption'; +import { compareServerVersion } from '../../utils'; +import roomTypeToApiType, { RoomTypes } from '../methods/roomTypeToApiType'; +import sdk from './sdk'; export const createChannel = ({ name, @@ -758,6 +759,15 @@ export const useInviteToken = (token: string): any => // @ts-ignore sdk.post('useInviteToken', { token }); +export const readThreads = (tmid: string): Promise => { + const serverVersion = store.getState().server.version; + if (compareServerVersion(serverVersion, 'greaterThanOrEqualTo', '3.4.0')) { + // RC 3.4.0 + return sdk.methodCallWrapper('readThreads', tmid); + } + return Promise.resolve(); +}; + export const createGroupChat = () => { const { users } = reduxStore.getState().selectedUsers; const usernames = users.map(u => u.name).join(',');