about summary refs log tree commit diff
diff options
context:
space:
mode:
authorunarist <m.unarist@gmail.com>2017-06-05 22:20:46 +0900
committerEugen Rochko <eugen@zeonfederated.com>2017-06-05 15:20:46 +0200
commitc26cea262b7673b0b239dd1da6754e7788aa08d8 (patch)
tree5aeaca51ded65d0ce3c2c9a6f12e028fccae214b
parent1f1d6bf2a07219c9dfd04db5b98e31a0543a7427 (diff)
Prevent pinned columns from scroll to top on URL changing (#3586)
-rw-r--r--app/javascript/mastodon/components/status_list.js17
-rw-r--r--app/javascript/mastodon/features/community_timeline/index.js1
-rw-r--r--app/javascript/mastodon/features/hashtag_timeline/index.js1
-rw-r--r--app/javascript/mastodon/features/home_timeline/index.js1
-rw-r--r--app/javascript/mastodon/features/notifications/index.js15
-rw-r--r--app/javascript/mastodon/features/public_timeline/index.js1
6 files changed, 27 insertions, 9 deletions
diff --git a/app/javascript/mastodon/components/status_list.js b/app/javascript/mastodon/components/status_list.js
index 9ee3af4d1..39909d98b 100644
--- a/app/javascript/mastodon/components/status_list.js
+++ b/app/javascript/mastodon/components/status_list.js
@@ -15,6 +15,7 @@ class StatusList extends ImmutablePureComponent {
     onScrollToBottom: PropTypes.func,
     onScrollToTop: PropTypes.func,
     onScroll: PropTypes.func,
+    trackScroll: PropTypes.bool,
     shouldUpdateScroll: PropTypes.func,
     isLoading: PropTypes.bool,
     isUnread: PropTypes.bool,
@@ -88,7 +89,7 @@ class StatusList extends ImmutablePureComponent {
   }
 
   render () {
-    const { statusIds, onScrollToBottom, scrollKey, shouldUpdateScroll, isLoading, isUnread, hasMore, prepend, emptyMessage } = this.props;
+    const { statusIds, onScrollToBottom, scrollKey, trackScroll, shouldUpdateScroll, isLoading, isUnread, hasMore, prepend, emptyMessage } = this.props;
 
     let loadMore       = null;
     let scrollableArea = null;
@@ -126,11 +127,15 @@ class StatusList extends ImmutablePureComponent {
       );
     }
 
-    return (
-      <ScrollContainer scrollKey={scrollKey} shouldUpdateScroll={shouldUpdateScroll}>
-        {scrollableArea}
-      </ScrollContainer>
-    );
+    if (trackScroll) {
+      return (
+        <ScrollContainer scrollKey={scrollKey} shouldUpdateScroll={shouldUpdateScroll}>
+          {scrollableArea}
+        </ScrollContainer>
+      );
+    } else {
+      return scrollableArea;
+    }
   }
 
 }
diff --git a/app/javascript/mastodon/features/community_timeline/index.js b/app/javascript/mastodon/features/community_timeline/index.js
index 6d2581141..1dd8a08ab 100644
--- a/app/javascript/mastodon/features/community_timeline/index.js
+++ b/app/javascript/mastodon/features/community_timeline/index.js
@@ -124,6 +124,7 @@ class CommunityTimeline extends React.PureComponent {
 
         <StatusListContainer
           {...this.props}
+          trackScroll={!pinned}
           scrollKey={`community_timeline-${columnId}`}
           type='community'
           emptyMessage={<FormattedMessage id='empty_column.community' defaultMessage='The local timeline is empty. Write something publicly to get the ball rolling!' />}
diff --git a/app/javascript/mastodon/features/hashtag_timeline/index.js b/app/javascript/mastodon/features/hashtag_timeline/index.js
index 7f7b3e075..da43e9403 100644
--- a/app/javascript/mastodon/features/hashtag_timeline/index.js
+++ b/app/javascript/mastodon/features/hashtag_timeline/index.js
@@ -120,6 +120,7 @@ class HashtagTimeline extends React.PureComponent {
         />
 
         <StatusListContainer
+          trackScroll={!pinned}
           scrollKey={`hashtag_timeline-${columnId}`}
           type='tag'
           id={id}
diff --git a/app/javascript/mastodon/features/home_timeline/index.js b/app/javascript/mastodon/features/home_timeline/index.js
index a0a62eaf6..a8d213340 100644
--- a/app/javascript/mastodon/features/home_timeline/index.js
+++ b/app/javascript/mastodon/features/home_timeline/index.js
@@ -81,6 +81,7 @@ class HomeTimeline extends React.PureComponent {
 
         <StatusListContainer
           {...this.props}
+          trackScroll={!pinned}
           scrollKey={`home_timeline-${columnId}`}
           type='home'
           emptyMessage={emptyMessage}
diff --git a/app/javascript/mastodon/features/notifications/index.js b/app/javascript/mastodon/features/notifications/index.js
index 60d8fff95..357c80c66 100644
--- a/app/javascript/mastodon/features/notifications/index.js
+++ b/app/javascript/mastodon/features/notifications/index.js
@@ -119,6 +119,7 @@ class Notifications extends React.PureComponent {
     let loadMore       = '';
     let scrollableArea = '';
     let unread         = '';
+    let scrollContainer = '';
 
     if (!isLoading && notifications.size > 0) {
       loadMore = <LoadMore onClick={this.handleLoadMore} />;
@@ -149,6 +150,16 @@ class Notifications extends React.PureComponent {
       );
     }
 
+    if (pinned) {
+      scrollContainer = scrollableArea;
+    } else {
+      scrollContainer = (
+        <ScrollContainer scrollKey={`notifications-${columnId}`} shouldUpdateScroll={shouldUpdateScroll}>
+          {scrollableArea}
+        </ScrollContainer>
+      );
+    }
+
     this.scrollableArea = scrollableArea;
 
     return (
@@ -166,9 +177,7 @@ class Notifications extends React.PureComponent {
           <ColumnSettingsContainer />
         </ColumnHeader>
 
-        <ScrollContainer scrollKey={`notifications-${columnId}`} shouldUpdateScroll={shouldUpdateScroll}>
-          {scrollableArea}
-        </ScrollContainer>
+        {scrollContainer}
       </Column>
     );
   }
diff --git a/app/javascript/mastodon/features/public_timeline/index.js b/app/javascript/mastodon/features/public_timeline/index.js
index 001632004..988e5a059 100644
--- a/app/javascript/mastodon/features/public_timeline/index.js
+++ b/app/javascript/mastodon/features/public_timeline/index.js
@@ -125,6 +125,7 @@ class PublicTimeline extends React.PureComponent {
         <StatusListContainer
           {...this.props}
           type='public'
+          trackScroll={!pinned}
           scrollKey={`public_timeline-${columnId}`}
           emptyMessage={<FormattedMessage id='empty_column.public' defaultMessage='There is nothing here! Write something publicly, or manually follow users from other instances to fill it up' />}
         />