Skip to content

Commit

Permalink
[FIX] Load messages issue when trying to get ts from empty results (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
djorkaeffalexandre authored Jun 12, 2020
1 parent 2cc599c commit 48be676
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions app/views/RoomView/List.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
Expand Down

0 comments on commit 48be676

Please sign in to comment.