Merge pull request #4039 from matrix-org/jryans/rvs-spam

Only emit in RoomViewStore when state actually changes
pull/21833/head
J. Ryan Stinnett 2020-02-06 21:12:54 +00:00 committed by GitHub
commit a160fbf0cc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 14 additions and 0 deletions

View File

@ -66,6 +66,20 @@ class RoomViewStore extends Store {
}
_setState(newState) {
// If values haven't changed, there's nothing to do.
// This only tries a shallow comparison, so unchanged objects will slip
// through, but that's probably okay for now.
let stateChanged = false;
for (const key of Object.keys(newState)) {
if (this._state[key] !== newState[key]) {
stateChanged = true;
break;
}
}
if (!stateChanged) {
return;
}
this._state = Object.assign(this._state, newState);
this.__emitChange();
}