mirror of
https://github.com/vector-im/element-web.git
synced 2024-11-17 05:55:00 +08:00
Only emit in RoomViewStore when state actually changes
This adds a shallow state check to attempt to only emit a store update when something actually changes. Fixes https://github.com/vector-im/riot-web/issues/12256
This commit is contained in:
parent
f89ae19d76
commit
c916ef4534
@ -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();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user