diff --git a/app/containers/MessageBox/index.tsx b/app/containers/MessageBox/index.tsx index 2143eb630..7ef49227a 100644 --- a/app/containers/MessageBox/index.tsx +++ b/app/containers/MessageBox/index.tsx @@ -609,7 +609,7 @@ class MessageBox extends Component { 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 = () => { diff --git a/app/definitions/rest/v1/omnichannel.ts b/app/definitions/rest/v1/omnichannel.ts index 7b5dcb64d..4d2350c92 100644 --- a/app/definitions/rest/v1/omnichannel.ts +++ b/app/definitions/rest/v1/omnichannel.ts @@ -1,3 +1,4 @@ +import { ICannedResponse } from '../../ICannedResponse'; import { ILivechatAgent } from '../../ILivechatAgent'; import { ILivechatDepartment } from '../../ILivechatDepartment'; import { ILivechatDepartmentAgents } from '../../ILivechatDepartmentAgents'; @@ -190,4 +191,10 @@ export type OmnichannelEndpoints = { total: number; }; }; + + 'canned-responses': { + GET: (params: PaginatedRequest<{ scope?: string; departmentId?: string; text?: string }>) => PaginatedResult<{ + cannedResponses: ICannedResponse[]; + }>; + }; }; diff --git a/app/lib/rocketchat/services/restApi.ts b/app/lib/rocketchat/services/restApi.ts index 0f66e9609..825abed0d 100644 --- a/app/lib/rocketchat/services/restApi.ts +++ b/app/lib/rocketchat/services/restApi.ts @@ -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, @@ -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); };