2021-10-01 18:12:19 +00:00
|
|
|
import {
|
|
|
|
MESSAGE_TYPE_LOAD_MORE,
|
|
|
|
MESSAGE_TYPE_LOAD_NEXT_CHUNK,
|
|
|
|
MESSAGE_TYPE_LOAD_PREVIOUS_CHUNK
|
|
|
|
} from '../../../constants/messageTypeLoad';
|
2021-06-15 20:13:42 +00:00
|
|
|
import RocketChat from '../../../lib/rocketchat';
|
|
|
|
|
2021-10-01 18:12:19 +00:00
|
|
|
const getMoreMessages = ({ rid, t, tmid, loaderItem }) => {
|
2021-06-15 20:13:42 +00:00
|
|
|
if ([MESSAGE_TYPE_LOAD_MORE, MESSAGE_TYPE_LOAD_PREVIOUS_CHUNK].includes(loaderItem.t)) {
|
|
|
|
return RocketChat.loadMessagesForRoom({
|
2021-10-01 18:12:19 +00:00
|
|
|
rid,
|
|
|
|
t,
|
|
|
|
latest: loaderItem.ts,
|
|
|
|
loaderItem
|
2021-06-15 20:13:42 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
if (loaderItem.t === MESSAGE_TYPE_LOAD_NEXT_CHUNK) {
|
|
|
|
return RocketChat.loadNextMessages({
|
2021-10-01 18:12:19 +00:00
|
|
|
rid,
|
|
|
|
tmid,
|
|
|
|
ts: loaderItem.ts,
|
|
|
|
loaderItem
|
2021-06-15 20:13:42 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
};
|
|
|
|
export default getMoreMessages;
|