bug fix: keep message panel at the bottom on new messages
This commit is contained in:
+11
-10
@@ -606,17 +606,18 @@ class MessagesView extends React.Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
clearTimeout(this.keyPressTimer)
|
clearTimeout(this.keyPressTimer)
|
||||||
this.setState({messageCount: topic.messageCount(), typingIndicator: false});
|
this.setState({messageCount: topic.messageCount(), typingIndicator: false}, _ => {
|
||||||
|
// Scroll to the bottom if the message is added to the end of the message
|
||||||
// Scroll to the bottom if the message is added to the end of the message
|
// list if already at the bottom, otherwise show [go to latest] button.
|
||||||
// list if already at the bottom, otherwise show [go to latest] button.
|
// Implemented as a callback to be sure the scroll height has been updated.
|
||||||
if (topic.isNewMessage(msg.seq)) {
|
if (topic.isNewMessage(msg.seq)) {
|
||||||
if (this.state.scrollPosition > SHOW_GO_TO_LAST_DIST) {
|
if (this.state.scrollPosition > SHOW_GO_TO_LAST_DIST) {
|
||||||
this.setState({showGoToLastButton: true});
|
this.setState({showGoToLastButton: true});
|
||||||
} else {
|
} else {
|
||||||
this.setState({scrollPosition: 0});
|
this.goToLatestMessage();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
|
|
||||||
// Aknowledge messages except own messages. They are
|
// Aknowledge messages except own messages. They are
|
||||||
// automatically assumed to be read and recived.
|
// automatically assumed to be read and recived.
|
||||||
|
|||||||
+10
-13
@@ -6011,20 +6011,17 @@ class MessagesView extends (react__WEBPACK_IMPORTED_MODULE_0___default().Compone
|
|||||||
this.setState({
|
this.setState({
|
||||||
messageCount: topic.messageCount(),
|
messageCount: topic.messageCount(),
|
||||||
typingIndicator: false
|
typingIndicator: false
|
||||||
});
|
}, _ => {
|
||||||
|
if (topic.isNewMessage(msg.seq)) {
|
||||||
if (topic.isNewMessage(msg.seq)) {
|
if (this.state.scrollPosition > SHOW_GO_TO_LAST_DIST) {
|
||||||
if (this.state.scrollPosition > SHOW_GO_TO_LAST_DIST) {
|
this.setState({
|
||||||
this.setState({
|
showGoToLastButton: true
|
||||||
showGoToLastButton: true
|
});
|
||||||
});
|
} else {
|
||||||
} else {
|
this.goToLatestMessage();
|
||||||
this.setState({
|
}
|
||||||
scrollPosition: 0
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
|
|
||||||
const status = topic.msgStatus(msg, true);
|
const status = topic.msgStatus(msg, true);
|
||||||
|
|
||||||
if (status >= tinode_sdk__WEBPACK_IMPORTED_MODULE_2__.Tinode.MESSAGE_STATUS_SENT && msg.from != this.props.myUserId) {
|
if (status >= tinode_sdk__WEBPACK_IMPORTED_MODULE_2__.Tinode.MESSAGE_STATUS_SENT && msg.from != this.props.myUserId) {
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
+1
-1
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user