Cache hidden events setting

Settings is too expensive to query in a hot code path, so this caches the value
on the MessagePanel component instead.
This commit is contained in:
J. Ryan Stinnett 2019-06-04 15:07:23 +01:00
parent e5abb2e089
commit 06547ef5b3

View file

@ -152,6 +152,11 @@ module.exports = React.createClass({
// Velocity requires // Velocity requires
this._readMarkerGhostNode = null; this._readMarkerGhostNode = null;
// Cache hidden events setting on mount since Settings is expensive to
// query, and we check this in a hot code path.
this._showHiddenEventsInTimeline =
SettingsStore.getValue("showHiddenEventsInTimeline");
this._isMounted = true; this._isMounted = true;
}, },
@ -292,7 +297,7 @@ module.exports = React.createClass({
return false; // ignored = no show (only happens if the ignore happens after an event was received) return false; // ignored = no show (only happens if the ignore happens after an event was received)
} }
if (SettingsStore.getValue("showHiddenEventsInTimeline")) { if (this._showHiddenEventsInTimeline) {
return true; return true;
} }