From a2eb0a9cf0a5c54360921fc49fce887a34d18ec9 Mon Sep 17 00:00:00 2001 From: David Baker Date: Wed, 26 Oct 2016 13:09:53 +0100 Subject: [PATCH] Fix CPU spin on joining rooms Ratelimit roomheader's updates and move some other things into rate limited functions. --- src/components/structures/RoomView.js | 11 +++++------ src/components/views/rooms/RoomHeader.js | 7 ++++++- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/components/structures/RoomView.js b/src/components/structures/RoomView.js index c6b577da5f..84c18b8018 100644 --- a/src/components/structures/RoomView.js +++ b/src/components/structures/RoomView.js @@ -573,18 +573,17 @@ module.exports = React.createClass({ return; } - if (this.props.ConferenceHandler && - member.userId === this.props.ConferenceHandler.getConferenceUserIdForRoom(member.roomId)) { - this._updateConfCallNotification(); - } - this._updateRoomMembers(); }, // rate limited because a power level change will emit an event for every // member in the room. _updateRoomMembers: new rate_limited_func(function() { - // a member state changed in this room, refresh the tab complete list + // a member state changed in this room + // refresh, the conf call notification state + this._updateConfCallNotification(); + + // refresh the tab complete list this.tabComplete.loadEntries(this.state.room); this._updateAutoComplete(); diff --git a/src/components/views/rooms/RoomHeader.js b/src/components/views/rooms/RoomHeader.js index 984862c13b..db3c7bb3d9 100644 --- a/src/components/views/rooms/RoomHeader.js +++ b/src/components/views/rooms/RoomHeader.js @@ -21,6 +21,7 @@ var sdk = require('../../../index'); var MatrixClientPeg = require('../../../MatrixClientPeg'); var Modal = require("../../../Modal"); var dis = require("../../../dispatcher"); +var rate_limited_func = require('../../../ratelimitedfunc'); var linkify = require('linkifyjs'); var linkifyElement = require('linkifyjs/element'); @@ -85,9 +86,13 @@ module.exports = React.createClass({ } // redisplay the room name, topic, etc. - this.forceUpdate(); + this._rateLimitedUpdate(); }, + _rateLimitedUpdate: new rate_limited_func(function() { + this.forceUpdate(); + }, 500), + _onRoomNameChange: function(room) { this.forceUpdate(); },