Chore: Migrate REST API - getCommandPreview to Typescript (#3894)

This commit is contained in:
Alex Junior 2022-03-14 23:16:53 -03:00 committed by GitHub
parent 6d543c28d9
commit 8a1f81d707
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 18 additions and 8 deletions

View File

@ -638,12 +638,12 @@ class MessageBox extends Component<IMessageBoxProps, IMessageBoxState> {
}, 1000); }, 1000);
}; };
setCommandPreview = async (command: any, name: string, params: any) => { setCommandPreview = async (command: any, name: string, params: string) => {
const { rid } = this.props; const { rid } = this.props;
try { try {
const { success, preview } = await RocketChat.getCommandPreview(name, rid, params); const response = await RocketChat.getCommandPreview(name, rid, params);
if (success) { if (response.success) {
return this.setState({ commandPreview: preview?.items, showCommandPreview: true, command }); return this.setState({ commandPreview: response.preview?.items, showCommandPreview: true, command });
} }
} catch (e) { } catch (e) {
log(e); log(e);

View File

@ -0,0 +1,10 @@
export type CommandsEndpoints = {
'commands.preview': {
GET: (params: { command: string; roomId: string; params: string }) => {
preview: {
i18nTitle: string;
items: any;
};
};
};
};

View File

@ -16,6 +16,7 @@ import { TeamsEndpoints } from './teams';
import { E2eEndpoints } from './e2e'; import { E2eEndpoints } from './e2e';
import { SubscriptionsEndpoints } from './subscriptions'; import { SubscriptionsEndpoints } from './subscriptions';
import { VideoConferenceEndpoints } from './videoConference'; import { VideoConferenceEndpoints } from './videoConference';
import { CommandsEndpoints } from './commands';
export type Endpoints = ChannelsEndpoints & export type Endpoints = ChannelsEndpoints &
ChatEndpoints & ChatEndpoints &
@ -34,4 +35,5 @@ export type Endpoints = ChannelsEndpoints &
TeamsEndpoints & TeamsEndpoints &
E2eEndpoints & E2eEndpoints &
SubscriptionsEndpoints & SubscriptionsEndpoints &
VideoConferenceEndpoints; VideoConferenceEndpoints &
CommandsEndpoints;

View File

@ -686,10 +686,8 @@ export const runSlashCommand = (command: string, roomId: string, params: any, tr
tmid tmid
}); });
export const getCommandPreview = (command: string, roomId: string, params: any): any => export const getCommandPreview = (command: string, roomId: string, params: string) =>
// RC 0.65.0 // RC 0.65.0
// TODO: missing definitions from server
// @ts-ignore
sdk.get('commands.preview', { sdk.get('commands.preview', {
command, command,
roomId, roomId,