Chore: Migrate REST API - getCommandPreview to Typescript (#3894)
This commit is contained in:
parent
6d543c28d9
commit
8a1f81d707
|
@ -638,12 +638,12 @@ class MessageBox extends Component<IMessageBoxProps, IMessageBoxState> {
|
|||
}, 1000);
|
||||
};
|
||||
|
||||
setCommandPreview = async (command: any, name: string, params: any) => {
|
||||
setCommandPreview = async (command: any, name: string, params: string) => {
|
||||
const { rid } = this.props;
|
||||
try {
|
||||
const { success, preview } = await RocketChat.getCommandPreview(name, rid, params);
|
||||
if (success) {
|
||||
return this.setState({ commandPreview: preview?.items, showCommandPreview: true, command });
|
||||
const response = await RocketChat.getCommandPreview(name, rid, params);
|
||||
if (response.success) {
|
||||
return this.setState({ commandPreview: response.preview?.items, showCommandPreview: true, command });
|
||||
}
|
||||
} catch (e) {
|
||||
log(e);
|
||||
|
|
|
@ -0,0 +1,10 @@
|
|||
export type CommandsEndpoints = {
|
||||
'commands.preview': {
|
||||
GET: (params: { command: string; roomId: string; params: string }) => {
|
||||
preview: {
|
||||
i18nTitle: string;
|
||||
items: any;
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
|
@ -16,6 +16,7 @@ import { TeamsEndpoints } from './teams';
|
|||
import { E2eEndpoints } from './e2e';
|
||||
import { SubscriptionsEndpoints } from './subscriptions';
|
||||
import { VideoConferenceEndpoints } from './videoConference';
|
||||
import { CommandsEndpoints } from './commands';
|
||||
|
||||
export type Endpoints = ChannelsEndpoints &
|
||||
ChatEndpoints &
|
||||
|
@ -34,4 +35,5 @@ export type Endpoints = ChannelsEndpoints &
|
|||
TeamsEndpoints &
|
||||
E2eEndpoints &
|
||||
SubscriptionsEndpoints &
|
||||
VideoConferenceEndpoints;
|
||||
VideoConferenceEndpoints &
|
||||
CommandsEndpoints;
|
||||
|
|
|
@ -686,10 +686,8 @@ export const runSlashCommand = (command: string, roomId: string, params: any, tr
|
|||
tmid
|
||||
});
|
||||
|
||||
export const getCommandPreview = (command: string, roomId: string, params: any): any =>
|
||||
export const getCommandPreview = (command: string, roomId: string, params: string) =>
|
||||
// RC 0.65.0
|
||||
// TODO: missing definitions from server
|
||||
// @ts-ignore
|
||||
sdk.get('commands.preview', {
|
||||
command,
|
||||
roomId,
|
||||
|
|
Loading…
Reference in New Issue