Chore: Migrate REST API - readThreads to Typescript (#3866)

* chore: migrate readThreads to typescript

* fix imports
This commit is contained in:
Gleidson Daniel Silva 2022-03-15 16:53:24 -03:00 committed by GitHub
parent 1d04e9379f
commit 1aab65ef92
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 22 additions and 20 deletions

View File

@ -434,14 +434,6 @@ const RocketChat = {
getLoginServices, getLoginServices,
determineAuthType, determineAuthType,
roomTypeToApiType, 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) { _setUser(ddpMessage) {
this.activeUsers = this.activeUsers || {}; this.activeUsers = this.activeUsers || {};
const { user } = reduxStore.getState().login; const { user } = reduxStore.getState().login;

View File

@ -1,20 +1,21 @@
import sdk from './sdk';
import { TEAM_TYPE } from '../../../definitions/ITeam';
import roomTypeToApiType, { RoomTypes } from '../methods/roomTypeToApiType';
import { import {
SubscriptionType,
INotificationPreferences,
IRoomNotifications,
TRocketChat,
IMessage, IMessage,
INotificationPreferences,
IPreviewItem,
IRoom, IRoom,
IPreviewItem IRoomNotifications,
SubscriptionType,
TRocketChat
} from '../../../definitions'; } from '../../../definitions';
import { ISpotlight } from '../../../definitions/ISpotlight';
import { IAvatarSuggestion, IParams } from '../../../definitions/IProfileViewInterfaces';
import { Encryption } from '../../encryption';
import { TParams } from '../../../definitions/ILivechatEditView'; 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 = ({ export const createChannel = ({
name, name,
@ -758,6 +759,15 @@ export const useInviteToken = (token: string): any =>
// @ts-ignore // @ts-ignore
sdk.post('useInviteToken', { token }); sdk.post('useInviteToken', { token });
export const readThreads = (tmid: string): Promise<void> => {
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 = () => { export const createGroupChat = () => {
const { users } = reduxStore.getState().selectedUsers; const { users } = reduxStore.getState().selectedUsers;
const usernames = users.map(u => u.name).join(','); const usernames = users.map(u => u.name).join(',');