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 });
|
||||
}
|
||||
|
||||
scrollToBottom = () => {
|
||||
if (!this.messagesEnd) return;
|
||||
this.messagesEnd.scrollIntoView({ behavior: 'smooth' });
|
||||
}
|
||||
|
||||
setRef = (el) => this.messagesEnd = el;
|
||||
|
||||
componentDidMount() {
|
||||
const { dispatch, pane, chatMessages } = this.props;
|
||||
this.scrollToBottom();
|
||||
if (chatMessages && chatMessages.count() < 1)
|
||||
dispatch(fetchChatMessages(pane.get('chat_id')));
|
||||
}
|
||||
|
||||
componentDidUpdate() {
|
||||
this.scrollToBottom();
|
||||
}
|
||||
|
||||
render() {
|
||||
const { pane, idx, chatMessages } = this.props;
|
||||
const chat = pane.get('chat');
|
||||
|
@ -93,6 +105,7 @@ class ChatWindow extends ImmutablePureComponent {
|
|||
</span>
|
||||
</div>
|
||||
))}
|
||||
<div style={{ float: 'left', clear: 'both' }} ref={this.setRef} />
|
||||
</div>
|
||||
<div className='pane__actions'>
|
||||
<input
|
||||
|
|
Loading…
Reference in a new issue