diff --git a/app/soapbox/components/scrollable_list.js b/app/soapbox/components/scrollable_list.js index 16e394a78..3576960db 100644 --- a/app/soapbox/components/scrollable_list.js +++ b/app/soapbox/components/scrollable_list.js @@ -221,67 +221,82 @@ export default class ScrollableList extends PureComponent { this.node = c; } - render() { - const { children, scrollKey, showLoading, isLoading, hasMore, prepend, alwaysPrepend, emptyMessage, onLoadMore } = this.props; + renderLoading = () => { + const { prepend } = this.props; + + return ( +
+
+ {prepend} +
+ +
+ +
+
+ ); + } + + renderEmptyMessage = () => { + const { prepend, alwaysPrepend, emptyMessage } = this.props; + + return ( +
+ {alwaysPrepend && prepend} + +
+
{emptyMessage}
+
+
+ ); + } + + renderFeed = () => { + const { children, scrollKey, isLoading, hasMore, prepend, onLoadMore } = this.props; const childrenCount = React.Children.count(children); const trackScroll = true; //placeholder + const loadMore = (hasMore && onLoadMore) ? : null; - const loadMore = (hasMore && onLoadMore) ? : null; - let scrollableArea = null; + return ( +
+
+ {prepend} + + {React.Children.map(children, (child, index) => ( + + {React.cloneElement(child, { + getScrollPosition: this.getScrollPosition, + updateScrollBottom: this.updateScrollBottom, + cachedMediaWidth: this.state.cachedMediaWidth, + cacheMediaWidth: this.cacheMediaWidth, + })} + + ))} + {this.getMoreFollows()} + {loadMore} +
+
+ ); + } + + render() { + const { children, showLoading, isLoading, hasMore, emptyMessage } = this.props; + const childrenCount = React.Children.count(children); if (showLoading) { - scrollableArea = ( -
-
- {prepend} -
- -
- -
-
- ); + return this.renderLoading(); } else if (isLoading || childrenCount > 0 || hasMore || !emptyMessage) { - scrollableArea = ( -
-
- {prepend} - - {React.Children.map(this.props.children, (child, index) => ( - - {React.cloneElement(child, { - getScrollPosition: this.getScrollPosition, - updateScrollBottom: this.updateScrollBottom, - cachedMediaWidth: this.state.cachedMediaWidth, - cacheMediaWidth: this.cacheMediaWidth, - })} - - ))} - {this.getMoreFollows()} - {loadMore} -
-
- ); + return this.renderFeed(); } else { - scrollableArea = ( -
- {alwaysPrepend && prepend} - -
-
{emptyMessage}
-
-
- ); + return this.renderEmptyMessage(); } - - return scrollableArea; } }