@@ -253,7 +165,7 @@ export default class Status extends ImmutablePureComponent {
{media}
-
+
);
}
diff --git a/app/javascript/mastodon/components/status_list.js b/app/javascript/mastodon/components/status_list.js
index ca443c286..cbae28afe 100644
--- a/app/javascript/mastodon/components/status_list.js
+++ b/app/javascript/mastodon/components/status_list.js
@@ -1,12 +1,9 @@
import React from 'react';
import ImmutablePropTypes from 'react-immutable-proptypes';
-import { ScrollContainer } from 'react-router-scroll';
import PropTypes from 'prop-types';
import StatusContainer from '../containers/status_container';
-import LoadMore from './load_more';
import ImmutablePureComponent from 'react-immutable-pure-component';
-import IntersectionObserverWrapper from '../features/ui/util/intersection_observer_wrapper';
-import { throttle } from 'lodash';
+import ScrollableList from './scrollable_list';
export default class StatusList extends ImmutablePureComponent {
@@ -28,145 +25,21 @@ export default class StatusList extends ImmutablePureComponent {
trackScroll: true,
};
- intersectionObserverWrapper = new IntersectionObserverWrapper();
-
- handleScroll = throttle(() => {
- if (this.node) {
- const { scrollTop, scrollHeight, clientHeight } = this.node;
- const offset = scrollHeight - scrollTop - clientHeight;
- this._oldScrollPosition = scrollHeight - scrollTop;
-
- if (400 > offset && this.props.onScrollToBottom && !this.props.isLoading) {
- this.props.onScrollToBottom();
- } else if (scrollTop < 100 && this.props.onScrollToTop) {
- this.props.onScrollToTop();
- } else if (this.props.onScroll) {
- this.props.onScroll();
- }
- }
- }, 150, {
- trailing: true,
- });
-
- componentDidMount () {
- this.attachScrollListener();
- this.attachIntersectionObserver();
-
- // Handle initial scroll posiiton
- this.handleScroll();
- }
-
- componentDidUpdate (prevProps) {
- // Reset the scroll position when a new toot comes in in order not to
- // jerk the scrollbar around if you're already scrolled down the page.
- if (prevProps.statusIds.size < this.props.statusIds.size && this._oldScrollPosition && this.node.scrollTop > 0) {
- if (prevProps.statusIds.first() !== this.props.statusIds.first()) {
- let newScrollTop = this.node.scrollHeight - this._oldScrollPosition;
- if (this.node.scrollTop !== newScrollTop) {
- this.node.scrollTop = newScrollTop;
- }
- } else {
- this._oldScrollPosition = this.node.scrollHeight - this.node.scrollTop;
- }
- }
- }
-
- componentWillUnmount () {
- this.detachScrollListener();
- this.detachIntersectionObserver();
- }
-
- attachIntersectionObserver () {
- this.intersectionObserverWrapper.connect({
- root: this.node,
- rootMargin: '300% 0px',
- });
- }
-
- detachIntersectionObserver () {
- this.intersectionObserverWrapper.disconnect();
- }
-
- attachScrollListener () {
- this.node.addEventListener('scroll', this.handleScroll);
- }
-
- detachScrollListener () {
- this.node.removeEventListener('scroll', this.handleScroll);
- }
-
- setRef = (c) => {
- this.node = c;
- }
-
- handleLoadMore = (e) => {
- e.preventDefault();
- this.props.onScrollToBottom();
- }
-
- handleKeyDown = (e) => {
- if (['PageDown', 'PageUp'].includes(e.key) || (e.ctrlKey && ['End', 'Home'].includes(e.key))) {
- const article = (() => {
- switch (e.key) {
- case 'PageDown':
- return e.target.nodeName === 'ARTICLE' && e.target.nextElementSibling;
- case 'PageUp':
- return e.target.nodeName === 'ARTICLE' && e.target.previousElementSibling;
- case 'End':
- return this.node.querySelector('[role="feed"] > article:last-of-type');
- case 'Home':
- return this.node.querySelector('[role="feed"] > article:first-of-type');
- default:
- return null;
- }
- })();
-
-
- if (article) {
- e.preventDefault();
- article.focus();
- article.scrollIntoView();
- }
- }
- }
-
render () {
- const { statusIds, scrollKey, trackScroll, shouldUpdateScroll, isLoading, hasMore, prepend, emptyMessage } = this.props;
+ const { statusIds, ...other } = this.props;
+ const { isLoading } = other;
- const loadMore =
0 && hasMore} onClick={this.handleLoadMore} />;
- let scrollableArea = null;
+ const scrollableContent = (isLoading || statusIds.size > 0) ? (
+ statusIds.map((statusId) => (
+
+ ))
+ ) : null;
- if (isLoading || statusIds.size > 0 || !emptyMessage) {
- scrollableArea = (
-
-
- {prepend}
-
- {statusIds.map((statusId, index) => {
- return ;
- })}
-
- {loadMore}
-
-
- );
- } else {
- scrollableArea = (
-
- {emptyMessage}
-
- );
- }
-
- if (trackScroll) {
- return (
-
- {scrollableArea}
-
- );
- } else {
- return scrollableArea;
- }
+ return (
+
+ {scrollableContent}
+
+ );
}
}
diff --git a/app/javascript/mastodon/features/favourited_statuses/index.js b/app/javascript/mastodon/features/favourited_statuses/index.js
index d9ad9bc1f..82b16b369 100644
--- a/app/javascript/mastodon/features/favourited_statuses/index.js
+++ b/app/javascript/mastodon/features/favourited_statuses/index.js
@@ -16,6 +16,7 @@ const messages = defineMessages({
const mapStateToProps = state => ({
statusIds: state.getIn(['status_lists', 'favourites', 'items']),
+ hasMore: !!state.getIn(['status_lists', 'favourites', 'next']),
});
@connect(mapStateToProps)
@@ -28,6 +29,7 @@ export default class Favourites extends ImmutablePureComponent {
intl: PropTypes.object.isRequired,
columnId: PropTypes.string,
multiColumn: PropTypes.bool,
+ hasMore: PropTypes.bool,
};
componentWillMount () {
@@ -62,7 +64,7 @@ export default class Favourites extends ImmutablePureComponent {
}
render () {
- const { intl, statusIds, columnId, multiColumn } = this.props;
+ const { intl, statusIds, columnId, multiColumn, hasMore } = this.props;
const pinned = !!columnId;
return (
@@ -81,6 +83,7 @@ export default class Favourites extends ImmutablePureComponent {
trackScroll={!pinned}
statusIds={statusIds}
scrollKey={`favourited_statuses-${columnId}`}
+ hasMore={hasMore}
onScrollToBottom={this.handleScrollToBottom}
/>
diff --git a/app/javascript/mastodon/features/notifications/components/notification.js b/app/javascript/mastodon/features/notifications/components/notification.js
index 2992185fd..a608a5223 100644
--- a/app/javascript/mastodon/features/notifications/components/notification.js
+++ b/app/javascript/mastodon/features/notifications/components/notification.js
@@ -1,4 +1,5 @@
import React from 'react';
+import PropTypes from 'prop-types';
import ImmutablePropTypes from 'react-immutable-proptypes';
import StatusContainer from '../../../containers/status_container';
import AccountContainer from '../../../containers/account_container';
@@ -10,6 +11,7 @@ export default class Notification extends ImmutablePureComponent {
static propTypes = {
notification: ImmutablePropTypes.map.isRequired,
+ hidden: PropTypes.bool,
};
renderFollow (account, link) {
@@ -23,13 +25,13 @@ export default class Notification extends ImmutablePureComponent {
-