mirror of
https://github.com/owncast/owncast.git
synced 2024-11-29 11:39:08 +03:00
fix for #411
This commit is contained in:
parent
0bf8cf1dba
commit
5fe36f37bd
1 changed files with 10 additions and 4 deletions
|
@ -24,6 +24,7 @@ export default class Chat extends Component {
|
||||||
this.scrollableMessagesContainer = createRef();
|
this.scrollableMessagesContainer = createRef();
|
||||||
|
|
||||||
this.websocket = null;
|
this.websocket = null;
|
||||||
|
this.receivedFirstMessages = false;
|
||||||
|
|
||||||
this.getChatHistory = this.getChatHistory.bind(this);
|
this.getChatHistory = this.getChatHistory.bind(this);
|
||||||
this.receivedWebsocketMessage = this.receivedWebsocketMessage.bind(this);
|
this.receivedWebsocketMessage = this.receivedWebsocketMessage.bind(this);
|
||||||
|
@ -181,8 +182,8 @@ export default class Chat extends Component {
|
||||||
checkShouldScroll() {
|
checkShouldScroll() {
|
||||||
const { scrollTop, scrollHeight, clientHeight } = this.scrollableMessagesContainer.current;
|
const { scrollTop, scrollHeight, clientHeight } = this.scrollableMessagesContainer.current;
|
||||||
const fullyScrolled = scrollHeight - clientHeight;
|
const fullyScrolled = scrollHeight - clientHeight;
|
||||||
const shoudlScroll = scrollHeight >= clientHeight && fullyScrolled - scrollTop < MESSAGE_JUMPTOBOTTOM_BUFFER;
|
const shouldScroll = scrollHeight >= clientHeight && fullyScrolled - scrollTop < MESSAGE_JUMPTOBOTTOM_BUFFER;
|
||||||
return shoudlScroll;
|
return shouldScroll;
|
||||||
}
|
}
|
||||||
|
|
||||||
handleWindowResize() {
|
handleWindowResize() {
|
||||||
|
@ -195,8 +196,13 @@ export default class Chat extends Component {
|
||||||
if (numMutations) {
|
if (numMutations) {
|
||||||
const item = mutations[numMutations - 1];
|
const item = mutations[numMutations - 1];
|
||||||
if (item.type === 'childList' && item.addedNodes.length) {
|
if (item.type === 'childList' && item.addedNodes.length) {
|
||||||
if (this.newMessagesReceived || this.checkShouldScroll()) {
|
if (this.newMessagesReceived) {
|
||||||
this.scrollToBottom();
|
if (!this.receivedFirstMessages) {
|
||||||
|
this.scrollToBottom();
|
||||||
|
this.receivedFirstMessages = true;
|
||||||
|
} else if (this.checkShouldScroll()) {
|
||||||
|
this.scrollToBottom();
|
||||||
|
}
|
||||||
this.newMessagesReceived = false;
|
this.newMessagesReceived = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue