[FIX] Load messages issue when trying to get ts from empty results (#2185)

This commit is contained in:
Djorkaeff Alexandre 2020-06-12 15:46:27 -03:00 committed by GitHub
parent 2cc599cc5e
commit 48be6764f4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 2 deletions

View File

@ -171,7 +171,7 @@ class List extends React.Component {
onEndReached = debounce(async() => { onEndReached = debounce(async() => {
const { const {
loading, end, messages, latest = messages[messages.length - 1].ts loading, end, messages, latest = messages[messages.length - 1]?.ts
} = this.state; } = this.state;
if (loading || end) { if (loading || end) {
return; return;
@ -188,7 +188,7 @@ class List extends React.Component {
result = await RocketChat.loadMessagesForRoom({ rid, t, latest }); 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) { } catch (e) {
this.setState({ loading: false }); this.setState({ loading: false });
log(e); log(e);