From c26cea262b7673b0b239dd1da6754e7788aa08d8 Mon Sep 17 00:00:00 2001 From: unarist Date: Mon, 5 Jun 2017 22:20:46 +0900 Subject: [PATCH] Prevent pinned columns from scroll to top on URL changing (#3586) --- .../mastodon/components/status_list.js | 17 +++++++++++------ .../features/community_timeline/index.js | 1 + .../mastodon/features/hashtag_timeline/index.js | 1 + .../mastodon/features/home_timeline/index.js | 1 + .../mastodon/features/notifications/index.js | 15 ++++++++++++--- .../mastodon/features/public_timeline/index.js | 1 + 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 ( - - {scrollableArea} - - ); + if (trackScroll) { + return ( + + {scrollableArea} + + ); + } 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 { } 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 { /> 0) { loadMore = ; @@ -149,6 +150,16 @@ class Notifications extends React.PureComponent { ); } + if (pinned) { + scrollContainer = scrollableArea; + } else { + scrollContainer = ( + + {scrollableArea} + + ); + } + this.scrollableArea = scrollableArea; return ( @@ -166,9 +177,7 @@ class Notifications extends React.PureComponent { - - {scrollableArea} - + {scrollContainer} ); } 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 { } />