about summary refs log tree commit diff
diff options
context:
space:
mode:
authorNaoki Kosaka <n.k@mail.yukimochi.net>2017-06-06 02:18:26 +0900
committerEugen Rochko <eugen@zeonfederated.com>2017-06-05 19:18:26 +0200
commite859d6f259cfe4aa61c2e68a18db95d34d460b81 (patch)
tree3392abcf745a2d9306b775edd4f0fe47509a7e79
parenta0880edc6e95b4fa43039e3bfbe31ea078cef2e8 (diff)
Fix LoadMore in Notifications. (#3590)
-rw-r--r--app/javascript/mastodon/features/notifications/index.js10
1 files changed, 7 insertions, 3 deletions
diff --git a/app/javascript/mastodon/features/notifications/index.js b/app/javascript/mastodon/features/notifications/index.js
index 357c80c66..e2e035620 100644
--- a/app/javascript/mastodon/features/notifications/index.js
+++ b/app/javascript/mastodon/features/notifications/index.js
@@ -31,6 +31,7 @@ const mapStateToProps = state => ({
   notifications: getNotifications(state),
   isLoading: state.getIn(['notifications', 'isLoading'], true),
   isUnread: state.getIn(['notifications', 'unread']) > 0,
+  hasMore: !!state.getIn(['notifications', 'next']),
 });
 
 class Notifications extends React.PureComponent {
@@ -44,6 +45,7 @@ class Notifications extends React.PureComponent {
     isLoading: PropTypes.bool,
     isUnread: PropTypes.bool,
     multiColumn: PropTypes.bool,
+    hasMore: PropTypes.bool,
   };
 
   static defaultProps = {
@@ -56,7 +58,9 @@ class Notifications extends React.PureComponent {
     this._oldScrollPosition = scrollHeight - scrollTop;
 
     if (250 > offset && !this.props.isLoading) {
-      this.props.dispatch(expandNotifications());
+      if (this.props.hasMore) {
+        this.props.dispatch(expandNotifications());
+      }
     } else if (scrollTop < 100) {
       this.props.dispatch(scrollTopNotifications(true));
     } else {
@@ -113,7 +117,7 @@ class Notifications extends React.PureComponent {
   }
 
   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;
 
     let loadMore       = '';
@@ -121,7 +125,7 @@ class Notifications extends React.PureComponent {
     let unread         = '';
     let scrollContainer = '';
 
-    if (!isLoading && notifications.size > 0) {
+    if (!isLoading && notifications.size > 0 && hasMore) {
       loadMore = <LoadMore onClick={this.handleLoadMore} />;
     }