|
|
@ -1,4 +1,4 @@
|
|
|
|
import React, { PureComponent } from 'react';
|
|
|
|
import { Children, cloneElement, PureComponent } from 'react';
|
|
|
|
import ScrollContainer from 'mastodon/containers/scroll_container';
|
|
|
|
import ScrollContainer from 'mastodon/containers/scroll_container';
|
|
|
|
import PropTypes from 'prop-types';
|
|
|
|
import PropTypes from 'prop-types';
|
|
|
|
import IntersectionObserverArticleContainer from '../containers/intersection_observer_article_container';
|
|
|
|
import IntersectionObserverArticleContainer from '../containers/intersection_observer_article_container';
|
|
|
@ -184,8 +184,8 @@ class ScrollableList extends PureComponent {
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
getSnapshotBeforeUpdate (prevProps) {
|
|
|
|
getSnapshotBeforeUpdate (prevProps) {
|
|
|
|
const someItemInserted = React.Children.count(prevProps.children) > 0 &&
|
|
|
|
const someItemInserted = Children.count(prevProps.children) > 0 &&
|
|
|
|
React.Children.count(prevProps.children) < React.Children.count(this.props.children) &&
|
|
|
|
Children.count(prevProps.children) < Children.count(this.props.children) &&
|
|
|
|
this.getFirstChildKey(prevProps) !== this.getFirstChildKey(this.props);
|
|
|
|
this.getFirstChildKey(prevProps) !== this.getFirstChildKey(this.props);
|
|
|
|
const pendingChanged = (prevProps.numPending > 0) !== (this.props.numPending > 0);
|
|
|
|
const pendingChanged = (prevProps.numPending > 0) !== (this.props.numPending > 0);
|
|
|
|
|
|
|
|
|
|
|
@ -293,7 +293,7 @@ class ScrollableList extends PureComponent {
|
|
|
|
render () {
|
|
|
|
render () {
|
|
|
|
const { children, scrollKey, trackScroll, showLoading, isLoading, hasMore, numPending, prepend, alwaysPrepend, append, emptyMessage, onLoadMore } = this.props;
|
|
|
|
const { children, scrollKey, trackScroll, showLoading, isLoading, hasMore, numPending, prepend, alwaysPrepend, append, emptyMessage, onLoadMore } = this.props;
|
|
|
|
const { fullscreen } = this.state;
|
|
|
|
const { fullscreen } = this.state;
|
|
|
|
const childrenCount = React.Children.count(children);
|
|
|
|
const childrenCount = Children.count(children);
|
|
|
|
|
|
|
|
|
|
|
|
const loadMore = (hasMore && onLoadMore) ? <LoadMore visible={!isLoading} onClick={this.handleLoadMore} /> : null;
|
|
|
|
const loadMore = (hasMore && onLoadMore) ? <LoadMore visible={!isLoading} onClick={this.handleLoadMore} /> : null;
|
|
|
|
const loadPending = (numPending > 0) ? <LoadPending count={numPending} onClick={this.handleLoadPending} /> : null;
|
|
|
|
const loadPending = (numPending > 0) ? <LoadPending count={numPending} onClick={this.handleLoadPending} /> : null;
|
|
|
@ -319,7 +319,7 @@ class ScrollableList extends PureComponent {
|
|
|
|
|
|
|
|
|
|
|
|
{loadPending}
|
|
|
|
{loadPending}
|
|
|
|
|
|
|
|
|
|
|
|
{React.Children.map(this.props.children, (child, index) => (
|
|
|
|
{Children.map(this.props.children, (child, index) => (
|
|
|
|
<IntersectionObserverArticleContainer
|
|
|
|
<IntersectionObserverArticleContainer
|
|
|
|
key={child.key}
|
|
|
|
key={child.key}
|
|
|
|
id={child.key}
|
|
|
|
id={child.key}
|
|
|
@ -328,7 +328,7 @@ class ScrollableList extends PureComponent {
|
|
|
|
intersectionObserverWrapper={this.intersectionObserverWrapper}
|
|
|
|
intersectionObserverWrapper={this.intersectionObserverWrapper}
|
|
|
|
saveHeightKey={trackScroll ? `${this.context.router.route.location.key}:${scrollKey}` : null}
|
|
|
|
saveHeightKey={trackScroll ? `${this.context.router.route.location.key}:${scrollKey}` : null}
|
|
|
|
>
|
|
|
|
>
|
|
|
|
{React.cloneElement(child, {
|
|
|
|
{cloneElement(child, {
|
|
|
|
getScrollPosition: this.getScrollPosition,
|
|
|
|
getScrollPosition: this.getScrollPosition,
|
|
|
|
updateScrollBottom: this.updateScrollBottom,
|
|
|
|
updateScrollBottom: this.updateScrollBottom,
|
|
|
|
cachedMediaWidth: this.state.cachedMediaWidth,
|
|
|
|
cachedMediaWidth: this.state.cachedMediaWidth,
|
|
|
|