From 11e94b9017e3a8a3de6a8febb01d9f4ec38747ad Mon Sep 17 00:00:00 2001 From: Diego Mello Date: Mon, 29 Oct 2018 10:52:44 -0300 Subject: [PATCH] [FIX] Messages not being loaded properly (#513) --- app/lib/methods/loadMessagesForRoom.js | 2 +- app/lib/methods/loadMissedMessages.js | 4 ++-- app/views/RoomView/index.js | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/lib/methods/loadMessagesForRoom.js b/app/lib/methods/loadMessagesForRoom.js index 8d57d2c8..7f724de7 100644 --- a/app/lib/methods/loadMessagesForRoom.js +++ b/app/lib/methods/loadMessagesForRoom.js @@ -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 []; } diff --git a/app/lib/methods/loadMissedMessages.js b/app/lib/methods/loadMissedMessages.js index 225dc6f1..4bcdd0e3 100644 --- a/app/lib/methods/loadMissedMessages.js +++ b/app/lib/methods/loadMissedMessages.js @@ -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); diff --git a/app/views/RoomView/index.js b/app/views/RoomView/index.js index f5c546cb..05dbd087 100644 --- a/app/views/RoomView/index.js +++ b/app/views/RoomView/index.js @@ -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); }