diff --git a/app/lib/methods/loadNextMessages.js b/app/lib/methods/loadNextMessages.ts similarity index 74% rename from app/lib/methods/loadNextMessages.js rename to app/lib/methods/loadNextMessages.ts index 3fe728512..74f91d1f2 100644 --- a/app/lib/methods/loadNextMessages.js +++ b/app/lib/methods/loadNextMessages.ts @@ -7,13 +7,22 @@ import { getMessageById } from '../database/services/Message'; import { MESSAGE_TYPE_LOAD_NEXT_CHUNK } from '../../constants/messageTypeLoad'; import { generateLoadMoreId } from '../utils'; import updateMessages from './updateMessages'; +import { IMessage, TMessageModel } from '../../definitions'; +import RocketChat from '../rocketchat'; const COUNT = 50; -export default function loadNextMessages(args) { +interface ILoadNextMessages { + rid: string; + ts: string; + tmid: string; + loaderItem: TMessageModel; +} + +export default function loadNextMessages(args: ILoadNextMessages): Promise { return new Promise(async (resolve, reject) => { try { - const data = await this.methodCallWrapper('loadNextMessages', args.rid, args.ts, COUNT); + const data = await RocketChat.methodCallWrapper('loadNextMessages', args.rid, args.ts, COUNT); let messages = EJSON.fromJSONValue(data?.messages); messages = orderBy(messages, 'ts'); if (messages?.length) { @@ -31,9 +40,8 @@ export default function loadNextMessages(args) { } await updateMessages({ rid: args.rid, update: messages, loaderItem: args.loaderItem }); return resolve(messages); - } else { - return resolve([]); } + return resolve([]); } catch (e) { log(e); reject(e);