From 48be6764f44337c31ec33cea471135eeef43432b Mon Sep 17 00:00:00 2001 From: Djorkaeff Alexandre Date: Fri, 12 Jun 2020 15:46:27 -0300 Subject: [PATCH] [FIX] Load messages issue when trying to get ts from empty results (#2185) --- app/views/RoomView/List.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views/RoomView/List.js b/app/views/RoomView/List.js index eeec5dee4..97708c124 100644 --- a/app/views/RoomView/List.js +++ b/app/views/RoomView/List.js @@ -171,7 +171,7 @@ class List extends React.Component { onEndReached = debounce(async() => { const { - loading, end, messages, latest = messages[messages.length - 1].ts + loading, end, messages, latest = messages[messages.length - 1]?.ts } = this.state; if (loading || end) { return; @@ -188,7 +188,7 @@ class List extends React.Component { result = await RocketChat.loadMessagesForRoom({ rid, t, latest }); } - this.setState({ end: result.length < 50, loading: false, latest: result[result.length - 1].ts }, () => this.loadMoreMessages(result)); + this.setState({ end: result.length < 50, loading: false, latest: result[result.length - 1]?.ts }, () => this.loadMoreMessages(result)); } catch (e) { this.setState({ loading: false }); log(e);