Ensure CustomRoomTagStore doesn't fire useless updates
This could in theory cause double rendering of the room list under some conditions.
This commit is contained in:
parent
5f034ee4ed
commit
b91026fa89
2 changed files with 23 additions and 2 deletions
|
@ -22,6 +22,7 @@ import SettingsStore from "../settings/SettingsStore";
|
|||
import RoomListStore, {LISTS_UPDATE_EVENT} from "./room-list/RoomListStore";
|
||||
import {RoomNotificationStateStore} from "./notifications/RoomNotificationStateStore";
|
||||
import {isCustomTag} from "./room-list/models";
|
||||
import {objectHasDiff} from "../utils/objects";
|
||||
|
||||
function commonPrefix(a, b) {
|
||||
const len = Math.min(a.length, b.length);
|
||||
|
@ -107,7 +108,10 @@ class CustomRoomTagStore extends EventEmitter {
|
|||
}
|
||||
|
||||
_onListsUpdated = () => {
|
||||
this._setState({tags: this._getUpdatedTags()});
|
||||
const newTags = this._getUpdatedTags();
|
||||
if (!this._state.tags || objectHasDiff(this._state.tags, newTags)) {
|
||||
this._setState({tags: newTags});
|
||||
}
|
||||
};
|
||||
|
||||
_onDispatch(payload) {
|
||||
|
@ -134,7 +138,7 @@ class CustomRoomTagStore extends EventEmitter {
|
|||
|
||||
_getUpdatedTags() {
|
||||
if (!SettingsStore.isFeatureEnabled("feature_custom_tags")) {
|
||||
return;
|
||||
return {}; // none
|
||||
}
|
||||
|
||||
const newTagNames = Object.keys(RoomListStore.instance.orderedLists).filter(t => isCustomTag(t)).sort();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue