Skip to content

Commit

Permalink
Chore: Migrate REST API - getListCannedResponse to Typescript (Rocket…
Browse files Browse the repository at this point in the history
  • Loading branch information
reinaldonetof authored Mar 8, 2022
1 parent 3fab849 commit d57893f
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
2 changes: 1 addition & 1 deletion app/containers/MessageBox/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -609,7 +609,7 @@ class MessageBox extends Component<IMessageBoxProps, IMessageBoxState> {

getCannedResponses = debounce(async (text?: string) => {
const res = await RocketChat.getListCannedResponse({ text });
this.setState({ mentions: res?.cannedResponses || [], mentionLoading: false });
this.setState({ mentions: res.success ? res.cannedResponses : [], mentionLoading: false });
}, 500);

focus = () => {
Expand Down
7 changes: 7 additions & 0 deletions app/definitions/rest/v1/omnichannel.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { ICannedResponse } from '../../ICannedResponse';
import { ILivechatAgent } from '../../ILivechatAgent';
import { ILivechatDepartment } from '../../ILivechatDepartment';
import { ILivechatDepartmentAgents } from '../../ILivechatDepartmentAgents';
Expand Down Expand Up @@ -190,4 +191,10 @@ export type OmnichannelEndpoints = {
total: number;
};
};

'canned-responses': {
GET: (params: PaginatedRequest<{ scope?: string; departmentId?: string; text?: string }>) => PaginatedResult<{
cannedResponses: ICannedResponse[];
}>;
};
};
4 changes: 1 addition & 3 deletions app/lib/rocketchat/services/restApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,7 @@ export const getCustomFields = () =>
// RC 2.2.0
sdk.get('livechat/custom-fields');

export const getListCannedResponse = ({ scope = '', departmentId = '', offset = 0, count = 25, text = '' }): any => {
export const getListCannedResponse = ({ scope = '', departmentId = '', offset = 0, count = 25, text = '' }) => {
const params = {
offset,
count,
Expand All @@ -415,8 +415,6 @@ export const getListCannedResponse = ({ scope = '', departmentId = '', offset =
};

// RC 3.17.0
// TODO: missing definitions from server
// @ts-ignore
return sdk.get('canned-responses', params);
};

Expand Down

0 comments on commit d57893f

Please sign in to comment.