Avoid two-step rendering of statuses as much as possible
Cache width shared by Video player, MediaGallery and Cards at the ScrollableList level, pass it down through StatusList and Notifications.
This commit is contained in:
@@ -40,6 +40,7 @@ export default class ScrollableList extends PureComponent {
|
||||
|
||||
state = {
|
||||
fullscreen: null,
|
||||
cachedMediaWidth: 300,
|
||||
};
|
||||
|
||||
intersectionObserverWrapper = new IntersectionObserverWrapper();
|
||||
@@ -141,6 +142,10 @@ export default class ScrollableList extends PureComponent {
|
||||
this.setScrollTop(newScrollTop);
|
||||
}
|
||||
|
||||
cacheMediaWidth = (width) => {
|
||||
if (width && this.state.cachedMediaWidth != width) this.setState({ cachedMediaWidth: width });
|
||||
}
|
||||
|
||||
getSnapshotBeforeUpdate (prevProps, prevState) {
|
||||
const someItemInserted = React.Children.count(prevProps.children) > 0 &&
|
||||
React.Children.count(prevProps.children) < React.Children.count(this.props.children) &&
|
||||
@@ -252,7 +257,12 @@ export default class ScrollableList extends PureComponent {
|
||||
intersectionObserverWrapper={this.intersectionObserverWrapper}
|
||||
saveHeightKey={trackScroll ? `${this.context.router.route.location.key}:${scrollKey}` : null}
|
||||
>
|
||||
{React.cloneElement(child, {getScrollPosition: this.getScrollPosition, updateScrollBottom: this.updateScrollBottom})}
|
||||
{React.cloneElement(child, {
|
||||
getScrollPosition: this.getScrollPosition,
|
||||
updateScrollBottom: this.updateScrollBottom,
|
||||
cachedMediaWidth: this.state.cachedMediaWidth,
|
||||
cacheMediaWidth: this.cacheMediaWidth,
|
||||
})}
|
||||
</IntersectionObserverArticleContainer>
|
||||
))}
|
||||
|
||||
|
Reference in New Issue
Block a user