parent
5a7cc14812
commit
dcaadb2153
1 changed files with 13 additions and 0 deletions
|
@ -59,12 +59,24 @@ class ChatWindow extends ImmutablePureComponent {
|
||||||
this.setState({ content: e.target.value });
|
this.setState({ content: e.target.value });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
scrollToBottom = () => {
|
||||||
|
if (!this.messagesEnd) return;
|
||||||
|
this.messagesEnd.scrollIntoView({ behavior: 'smooth' });
|
||||||
|
}
|
||||||
|
|
||||||
|
setRef = (el) => this.messagesEnd = el;
|
||||||
|
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
const { dispatch, pane, chatMessages } = this.props;
|
const { dispatch, pane, chatMessages } = this.props;
|
||||||
|
this.scrollToBottom();
|
||||||
if (chatMessages && chatMessages.count() < 1)
|
if (chatMessages && chatMessages.count() < 1)
|
||||||
dispatch(fetchChatMessages(pane.get('chat_id')));
|
dispatch(fetchChatMessages(pane.get('chat_id')));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
componentDidUpdate() {
|
||||||
|
this.scrollToBottom();
|
||||||
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { pane, idx, chatMessages } = this.props;
|
const { pane, idx, chatMessages } = this.props;
|
||||||
const chat = pane.get('chat');
|
const chat = pane.get('chat');
|
||||||
|
@ -93,6 +105,7 @@ class ChatWindow extends ImmutablePureComponent {
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
))}
|
))}
|
||||||
|
<div style={{ float: 'left', clear: 'both' }} ref={this.setRef} />
|
||||||
</div>
|
</div>
|
||||||
<div className='pane__actions'>
|
<div className='pane__actions'>
|
||||||
<input
|
<input
|
||||||
|
|
Loading…
Reference in a new issue