Fix direct messages column not loading more items on scroll (#9102)

Fix #9097
This commit is contained in:
Eugen Rochko 2018-10-26 01:55:08 +02:00 committed by GitHub
parent a2e3401e48
commit 768b0f132d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 10 deletions

View File

@ -9,14 +9,14 @@ import { debounce } from 'lodash';
export default class ConversationsList extends ImmutablePureComponent { export default class ConversationsList extends ImmutablePureComponent {
static propTypes = { static propTypes = {
conversationIds: ImmutablePropTypes.list.isRequired, conversations: ImmutablePropTypes.list.isRequired,
hasMore: PropTypes.bool, hasMore: PropTypes.bool,
isLoading: PropTypes.bool, isLoading: PropTypes.bool,
onLoadMore: PropTypes.func, onLoadMore: PropTypes.func,
shouldUpdateScroll: PropTypes.func, shouldUpdateScroll: PropTypes.func,
}; };
getCurrentIndex = id => this.props.conversationIds.indexOf(id) getCurrentIndex = id => this.props.conversations.findIndex(x => x.get('id') === id)
handleMoveUp = id => { handleMoveUp = id => {
const elementIndex = this.getCurrentIndex(id) - 1; const elementIndex = this.getCurrentIndex(id) - 1;
@ -41,22 +41,22 @@ export default class ConversationsList extends ImmutablePureComponent {
} }
handleLoadOlder = debounce(() => { handleLoadOlder = debounce(() => {
const last = this.props.conversationIds.last(); const last = this.props.conversations.last();
if (last) { if (last && last.get('last_status')) {
this.props.onLoadMore(last); this.props.onLoadMore(last.get('last_status'));
} }
}, 300, { leading: true }) }, 300, { leading: true })
render () { render () {
const { conversationIds, onLoadMore, ...other } = this.props; const { conversations, onLoadMore, ...other } = this.props;
return ( return (
<ScrollableList {...other} onLoadMore={onLoadMore && this.handleLoadOlder} scrollKey='direct' ref={this.setRef}> <ScrollableList {...other} onLoadMore={onLoadMore && this.handleLoadOlder} scrollKey='direct' ref={this.setRef}>
{conversationIds.map(item => ( {conversations.map(item => (
<ConversationContainer <ConversationContainer
key={item} key={item.get('id')}
conversationId={item} conversationId={item.get('id')}
onMoveUp={this.handleMoveUp} onMoveUp={this.handleMoveUp}
onMoveDown={this.handleMoveDown} onMoveDown={this.handleMoveDown}
/> />

View File

@ -3,7 +3,7 @@ import ConversationsList from '../components/conversations_list';
import { expandConversations } from '../../../actions/conversations'; import { expandConversations } from '../../../actions/conversations';
const mapStateToProps = state => ({ const mapStateToProps = state => ({
conversationIds: state.getIn(['conversations', 'items']).map(x => x.get('id')), conversations: state.getIn(['conversations', 'items']),
isLoading: state.getIn(['conversations', 'isLoading'], true), isLoading: state.getIn(['conversations', 'isLoading'], true),
hasMore: state.getIn(['conversations', 'hasMore'], false), hasMore: state.getIn(['conversations', 'hasMore'], false),
}); });