Unverified Commit 6f27126f authored by Alex Junior's avatar Alex Junior Committed by GitHub
Browse files

Chore: Migrate methods/loadNextMessages to typescript (#3719)

* feat: update loadNextMessages to ts

* minor tweak

* chore: minor tweaks after merge with developer
parent afb91b49
......@@ -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<IMessage | []> {
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);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment