From 8efba39370e270b95b19e565519cacc3008cebb1 Mon Sep 17 00:00:00 2001 From: Reinaldo Neto <47038980+reinaldonetof@users.noreply.github.com> Date: Wed, 16 Mar 2022 16:46:23 -0300 Subject: [PATCH] Chore: Migrate REST API - removePushToken to Typescript (#3903) --- app/lib/rocketchat/rocketchat.js | 8 -------- app/lib/rocketchat/services/restApi.ts | 16 +++++++++++++--- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/app/lib/rocketchat/rocketchat.js b/app/lib/rocketchat/rocketchat.js index d4fecd1e3..788e93a0c 100644 --- a/app/lib/rocketchat/rocketchat.js +++ b/app/lib/rocketchat/rocketchat.js @@ -227,14 +227,6 @@ const RocketChat = { return resolve(); }); }, - removePushToken() { - const token = getDeviceToken(); - if (token) { - // RC 0.60.0 - return this.sdk.del('push.token', { token }); - } - return Promise.resolve(); - }, loadMissedMessages, loadMessagesForRoom, loadSurroundingMessages, diff --git a/app/lib/rocketchat/services/restApi.ts b/app/lib/rocketchat/services/restApi.ts index d01318989..703515698 100644 --- a/app/lib/rocketchat/services/restApi.ts +++ b/app/lib/rocketchat/services/restApi.ts @@ -8,12 +8,13 @@ import { IUser, TRocketChat } from '../../../definitions'; -import { TParams } from '../../../definitions/ILivechatEditView'; 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 { TParams } from '../../../definitions/ILivechatEditView'; +import { store as reduxStore } from '../../auxStore'; +import { getDeviceToken } from '../../../notifications/push'; import { compareServerVersion } from '../../utils'; import roomTypeToApiType, { RoomTypes } from '../methods/roomTypeToApiType'; import sdk from './sdk'; @@ -766,7 +767,7 @@ export const useInviteToken = (token: string): any => sdk.post('useInviteToken', { token }); export const readThreads = (tmid: string): Promise => { - const serverVersion = store.getState().server.version; + const serverVersion = reduxStore.getState().server.version; if (compareServerVersion(serverVersion, 'greaterThanOrEqualTo', '3.4.0')) { // RC 3.4.0 return sdk.methodCallWrapper('readThreads', tmid); @@ -812,6 +813,15 @@ export const editMessage = async (message: IMessage) => { return sdk.post('chat.update', { roomId: rid, msgId: message.id, text: msg }); }; +export const removePushToken = (): Promise => { + const token = getDeviceToken(); + if (token) { + // RC 0.60.0 + return sdk.current.del('push.token', { token }); + } + return Promise.resolve(); +}; + export const sendEmailCode = () => { const { username } = reduxStore.getState().login.user as IUser; // RC 3.1.0