[FIX] Messages not being loaded properly (#513)

This commit is contained in:
Diego Mello 2018-10-29 10:52:44 -03:00 committed by GitHub
parent 53014ce022
commit 11e94b9017
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 4 additions and 4 deletions

View File

@ -14,7 +14,7 @@ async function loadMessagesForRoomRest({ rid: roomId, latest, t }) {
if (latest) {
latest = new Date(latest).toISOString();
}
const data = await SDK.api.get(`${ types[t] }.history`, { roomId, latest });
const data = await SDK.api.get(`${ types[t] }.history`, { roomId, latest, count: 50 });
if (!data || data.status === 'error') {
return [];
}

View File

@ -10,7 +10,7 @@ async function loadMissedMessagesRest({ rid: roomId, lastOpen }) {
if (lastOpen) {
lastUpdate = new Date(lastOpen).toISOString();
}
const { result } = await SDK.api.get('chat.syncMessages', { roomId, lastUpdate });
const { result } = await SDK.api.get('chat.syncMessages', { roomId, lastUpdate, count: 50 });
return result;
}
@ -18,7 +18,7 @@ async function loadMissedMessagesDDP(...args) {
const [{ rid, lastOpen: lastUpdate }] = args;
try {
const result = await SDK.driver.asyncCall('messages/get', rid, { lastUpdate: new Date(lastUpdate) });
const result = await SDK.driver.asyncCall('messages/get', rid, { lastUpdate: new Date(lastUpdate), count: 50 });
return result;
} catch (e) {
return loadMissedMessagesRest.call(this, ...args);

View File

@ -162,7 +162,7 @@ export default class RoomView extends LoggedView {
const { room } = this.state;
try {
const result = await RocketChat.loadMessagesForRoom({ rid: this.rid, t: room.t, latest: lastRowData.ts });
this.internalSetState({ end: result < 20 });
this.internalSetState({ end: result < 50 });
} catch (e) {
log('RoomView.onEndReached', e);
}