Chore: Migrate REST API - removePushToken to Typescript (#3903)

This commit is contained in:
Reinaldo Neto 2022-03-16 16:46:23 -03:00 committed by GitHub
parent 823d4c658c
commit 8efba39370
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 11 deletions

View File

@ -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,

View File

@ -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<void> => {
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<boolean | void> => {
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