diff --git a/app/definitions/IMessage.ts b/app/definitions/IMessage.ts index 538d4d258..aa4a293e4 100644 --- a/app/definitions/IMessage.ts +++ b/app/definitions/IMessage.ts @@ -98,6 +98,7 @@ export interface IMessageFromServer { _id: string; username: string; }; + score?: number; } export interface ILoadMoreMessage { diff --git a/app/definitions/rest/v1/chat.ts b/app/definitions/rest/v1/chat.ts index 417d54a29..07edd43ed 100644 --- a/app/definitions/rest/v1/chat.ts +++ b/app/definitions/rest/v1/chat.ts @@ -60,4 +60,9 @@ export type ChatEndpoints = { 'chat.ignoreUser': { GET: (params: { rid: string; userId: string; ignore: boolean }) => {}; }; + 'chat.search': { + GET: (params: { roomId: IServerRoom['_id']; searchText: string; count: number; offset: number }) => { + messages: IMessageFromServer[]; + }; + }; }; diff --git a/app/lib/rocketchat/services/restApi.ts b/app/lib/rocketchat/services/restApi.ts index efe25d39f..9d486d7e9 100644 --- a/app/lib/rocketchat/services/restApi.ts +++ b/app/lib/rocketchat/services/restApi.ts @@ -624,10 +624,8 @@ export const getReadReceipts = (messageId: string): any => messageId }); -export const searchMessages = (roomId: string, searchText: string, count: number, offset: number): any => +export const searchMessages = (roomId: string, searchText: string, count: number, offset: number) => // RC 0.60.0 - // TODO: missing definitions from server - // @ts-ignore sdk.get('chat.search', { roomId, searchText, diff --git a/app/views/SearchMessagesView/index.tsx b/app/views/SearchMessagesView/index.tsx index 417b240c8..c2a48367b 100644 --- a/app/views/SearchMessagesView/index.tsx +++ b/app/views/SearchMessagesView/index.tsx @@ -157,11 +157,13 @@ class SearchMessagesView extends React.Component { try { const messages = await this.searchMessages(searchText); + // @ts-ignore TODO: find a way to deal with the difference between IMessageFromServer and TMessageModel expected by state this.setState(prevState => ({ messages: debounced ? messages : [...prevState.messages, ...messages], loading: false