mirror of
https://github.com/vector-im/element-web.git
synced 2024-11-16 21:24:59 +08:00
Merge pull request #2339 from matrix-org/travis/speed-up-room-list
Speed up room unread checks by not hitting the SettingsStore so often
This commit is contained in:
commit
780315817c
@ -38,18 +38,20 @@ function memberEventDiff(ev) {
|
||||
}
|
||||
|
||||
export default function shouldHideEvent(ev) {
|
||||
// Wrap getValue() for readability
|
||||
// Wrap getValue() for readability. Calling the SettingsStore can be
|
||||
// fairly resource heavy, so the checks below should avoid hitting it
|
||||
// where possible.
|
||||
const isEnabled = (name) => SettingsStore.getValue(name, ev.getRoomId());
|
||||
|
||||
// Hide redacted events
|
||||
if (isEnabled('hideRedactions') && ev.isRedacted()) return true;
|
||||
if (ev.isRedacted() && isEnabled('hideRedactions')) return true;
|
||||
|
||||
const eventDiff = memberEventDiff(ev);
|
||||
|
||||
if (eventDiff.isMemberEvent) {
|
||||
if (isEnabled('hideJoinLeaves') && (eventDiff.isJoin || eventDiff.isPart)) return true;
|
||||
if (isEnabled('hideAvatarChanges') && eventDiff.isAvatarChange) return true;
|
||||
if (isEnabled('hideDisplaynameChanges') && eventDiff.isDisplaynameChange) return true;
|
||||
if ((eventDiff.isJoin || eventDiff.isPart) && isEnabled('hideJoinLeaves')) return true;
|
||||
if (eventDiff.isAvatarChange && isEnabled('hideAvatarChanges')) return true;
|
||||
if (eventDiff.isDisplaynameChange && isEnabled('hideDisplaynameChanges')) return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
|
Loading…
Reference in New Issue
Block a user