From d18d91dd742b2290d9cff938e7caa2c0934dec5b Mon Sep 17 00:00:00 2001 From: Reinaldo Neto <47038980+reinaldonetof@users.noreply.github.com> Date: Mon, 14 Mar 2022 12:55:32 -0300 Subject: [PATCH] Chore: Migrate REST API - emitTyping to Typescript (#3886) --- app/lib/rocketchat/rocketchat.js | 7 ------- app/lib/rocketchat/services/restApi.ts | 18 +++++++++++++++++- 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/app/lib/rocketchat/rocketchat.js b/app/lib/rocketchat/rocketchat.js index b0b951d7..3fa21888 100644 --- a/app/lib/rocketchat/rocketchat.js +++ b/app/lib/rocketchat/rocketchat.js @@ -315,13 +315,6 @@ const RocketChat = { onStreamData(...args) { return sdk.onStreamData(...args); }, - emitTyping(room, typing = true) { - const { login, settings } = reduxStore.getState(); - const { UI_Use_Real_Name } = settings; - const { user } = login; - const name = UI_Use_Real_Name ? user.name : user.username; - return this.methodCall('stream-notify-room', `${room}/typing`, name, typing); - }, toggleFavorite, async getRoomMembers({ rid, allUsers, roomType, type, filter, skip = 0, limit = 10 }) { const serverVersion = reduxStore.getState().server.version; diff --git a/app/lib/rocketchat/services/restApi.ts b/app/lib/rocketchat/services/restApi.ts index 43d414a8..2ee8ee08 100644 --- a/app/lib/rocketchat/services/restApi.ts +++ b/app/lib/rocketchat/services/restApi.ts @@ -1,11 +1,19 @@ import sdk from './sdk'; import { TEAM_TYPE } from '../../../definitions/ITeam'; import roomTypeToApiType, { RoomTypes } from '../methods/roomTypeToApiType'; -import { SubscriptionType, INotificationPreferences, IRoomNotifications, TRocketChat, IMessage } from '../../../definitions'; +import { + SubscriptionType, + INotificationPreferences, + IRoomNotifications, + TRocketChat, + IMessage, + IRoom +} 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'; export const createChannel = ({ name, @@ -744,6 +752,14 @@ export const useInviteToken = (token: string): any => // @ts-ignore sdk.post('useInviteToken', { token }); +export const emitTyping = (room: IRoom, typing = true) => { + const { login, settings } = reduxStore.getState(); + const { UI_Use_Real_Name } = settings; + const { user } = login; + const name = UI_Use_Real_Name ? user.name : user.username; + return sdk.methodCall('stream-notify-room', `${room}/typing`, name, typing); +}; + export function e2eResetOwnKey(this: TRocketChat): Promise { // {} when TOTP is enabled // TODO: remove this