Skip to content

Commit

Permalink
cache currently-viewing status id to avoid calling redux with identic…
Browse files Browse the repository at this point in the history
…al value
  • Loading branch information
panarom committed Dec 28, 2019
1 parent 07e2614 commit c93df21
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions app/javascript/mastodon/components/status_list.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,12 @@ export default class StatusList extends ImmutablePureComponent {
this.props.onLoadMore(this.props.statusIds.size > 0 ? this.props.statusIds.last() : undefined);
}, 300, { leading: true })

updateCurrentlyViewingWithCache = (id) => {
if(this.cachedCurrentlyViewing === id) return;
this.cachedCurrentlyViewing = id;
this.props.updateCurrentlyViewing(id);
}

_selectChild (index, align_top) {
const container = this.node.node;
const element = container.querySelector(`article:nth-of-type(${index + 1}) .focusable`);
Expand All @@ -81,6 +87,7 @@ export default class StatusList extends ImmutablePureComponent {
render () {
const { statusIds, featuredStatusIds, shouldUpdateScroll, onLoadMore, timelineId, ...other } = this.props;
const { isLoading, isPartial } = other;
other.updateCurrentlyViewing = this.updateCurrentlyViewingWithCache;

if (isPartial) {
return <RegenerationIndicator />;
Expand Down

0 comments on commit c93df21

Please sign in to comment.