Skip to content

Commit c93df21

Browse files
committed
cache currently-viewing status id to avoid calling redux with identical value
1 parent 07e2614 commit c93df21

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

app/javascript/mastodon/components/status_list.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,12 @@ export default class StatusList extends ImmutablePureComponent {
6060
this.props.onLoadMore(this.props.statusIds.size > 0 ? this.props.statusIds.last() : undefined);
6161
}, 300, { leading: true })
6262

63+
updateCurrentlyViewingWithCache = (id) => {
64+
if(this.cachedCurrentlyViewing === id) return;
65+
this.cachedCurrentlyViewing = id;
66+
this.props.updateCurrentlyViewing(id);
67+
}
68+
6369
_selectChild (index, align_top) {
6470
const container = this.node.node;
6571
const element = container.querySelector(`article:nth-of-type(${index + 1}) .focusable`);
@@ -81,6 +87,7 @@ export default class StatusList extends ImmutablePureComponent {
8187
render () {
8288
const { statusIds, featuredStatusIds, shouldUpdateScroll, onLoadMore, timelineId, ...other } = this.props;
8389
const { isLoading, isPartial } = other;
90+
other.updateCurrentlyViewing = this.updateCurrentlyViewingWithCache;
8491

8592
if (isPartial) {
8693
return <RegenerationIndicator />;

0 commit comments

Comments
 (0)