Fix LoadMore in Notifications. (#3590)
parent
a0880edc6e
commit
e859d6f259
|
@ -31,6 +31,7 @@ const mapStateToProps = state => ({
|
||||||
notifications: getNotifications(state),
|
notifications: getNotifications(state),
|
||||||
isLoading: state.getIn(['notifications', 'isLoading'], true),
|
isLoading: state.getIn(['notifications', 'isLoading'], true),
|
||||||
isUnread: state.getIn(['notifications', 'unread']) > 0,
|
isUnread: state.getIn(['notifications', 'unread']) > 0,
|
||||||
|
hasMore: !!state.getIn(['notifications', 'next']),
|
||||||
});
|
});
|
||||||
|
|
||||||
class Notifications extends React.PureComponent {
|
class Notifications extends React.PureComponent {
|
||||||
|
@ -44,6 +45,7 @@ class Notifications extends React.PureComponent {
|
||||||
isLoading: PropTypes.bool,
|
isLoading: PropTypes.bool,
|
||||||
isUnread: PropTypes.bool,
|
isUnread: PropTypes.bool,
|
||||||
multiColumn: PropTypes.bool,
|
multiColumn: PropTypes.bool,
|
||||||
|
hasMore: PropTypes.bool,
|
||||||
};
|
};
|
||||||
|
|
||||||
static defaultProps = {
|
static defaultProps = {
|
||||||
|
@ -56,7 +58,9 @@ class Notifications extends React.PureComponent {
|
||||||
this._oldScrollPosition = scrollHeight - scrollTop;
|
this._oldScrollPosition = scrollHeight - scrollTop;
|
||||||
|
|
||||||
if (250 > offset && !this.props.isLoading) {
|
if (250 > offset && !this.props.isLoading) {
|
||||||
|
if (this.props.hasMore) {
|
||||||
this.props.dispatch(expandNotifications());
|
this.props.dispatch(expandNotifications());
|
||||||
|
}
|
||||||
} else if (scrollTop < 100) {
|
} else if (scrollTop < 100) {
|
||||||
this.props.dispatch(scrollTopNotifications(true));
|
this.props.dispatch(scrollTopNotifications(true));
|
||||||
} else {
|
} else {
|
||||||
|
@ -113,7 +117,7 @@ class Notifications extends React.PureComponent {
|
||||||
}
|
}
|
||||||
|
|
||||||
render () {
|
render () {
|
||||||
const { intl, notifications, shouldUpdateScroll, isLoading, isUnread, columnId, multiColumn } = this.props;
|
const { intl, notifications, shouldUpdateScroll, isLoading, isUnread, columnId, multiColumn, hasMore } = this.props;
|
||||||
const pinned = !!columnId;
|
const pinned = !!columnId;
|
||||||
|
|
||||||
let loadMore = '';
|
let loadMore = '';
|
||||||
|
@ -121,7 +125,7 @@ class Notifications extends React.PureComponent {
|
||||||
let unread = '';
|
let unread = '';
|
||||||
let scrollContainer = '';
|
let scrollContainer = '';
|
||||||
|
|
||||||
if (!isLoading && notifications.size > 0) {
|
if (!isLoading && notifications.size > 0 && hasMore) {
|
||||||
loadMore = <LoadMore onClick={this.handleLoadMore} />;
|
loadMore = <LoadMore onClick={this.handleLoadMore} />;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue