mirror of
https://github.com/element-hq/element-web
synced 2024-11-27 11:47:23 +03:00
Fix onRoomStateMember debouncing
Don't have debounced functions take arsg, because they won't be the same for each invocation.
This commit is contained in:
parent
4ecf5f6372
commit
31399254b6
2 changed files with 20 additions and 10 deletions
|
@ -482,9 +482,7 @@ module.exports = React.createClass({
|
|||
}
|
||||
},
|
||||
|
||||
// rate limited because a power level change will emit an event for every
|
||||
// member in the room.
|
||||
onRoomStateMember: new rate_limited_func(function(ev, state, member) {
|
||||
onRoomStateMember: function(ev, state, member) {
|
||||
// ignore if we don't have a room yet
|
||||
if (!this.state.room) {
|
||||
return;
|
||||
|
@ -495,6 +493,15 @@ module.exports = React.createClass({
|
|||
return;
|
||||
}
|
||||
|
||||
if (this.props.ConferenceHandler &&
|
||||
member.userId === this.props.ConferenceHandler.getConferenceUserIdForRoom(member.roomId)) {
|
||||
this._updateConfCallNotification();
|
||||
}
|
||||
|
||||
this._updateRoomMembers();
|
||||
},
|
||||
|
||||
_updateRoomMembers: new rate_limited_func(function() {
|
||||
// a member state changed in this room, refresh the tab complete list
|
||||
this.tabComplete.loadEntries(this.state.room);
|
||||
this._updateAutoComplete();
|
||||
|
@ -508,11 +515,6 @@ module.exports = React.createClass({
|
|||
joining: false
|
||||
});
|
||||
}
|
||||
|
||||
if (this.props.ConferenceHandler &&
|
||||
member.userId === this.props.ConferenceHandler.getConferenceUserIdForRoom(member.roomId)) {
|
||||
this._updateConfCallNotification();
|
||||
}
|
||||
}, 500),
|
||||
|
||||
_hasUnsentMessages: function(room) {
|
||||
|
|
|
@ -14,6 +14,14 @@ See the License for the specific language governing permissions and
|
|||
limitations under the License.
|
||||
*/
|
||||
|
||||
/**
|
||||
* 'debounces' a function to only execute every n milliseconds.
|
||||
* Useful when react-sdk gets many, many events but only wants
|
||||
* to update the interface once for all of them.
|
||||
*
|
||||
* Note that the function must not take arguments, since the args
|
||||
* could be different for each invocarion of the function.
|
||||
*/
|
||||
module.exports = function(f, minIntervalMs) {
|
||||
this.lastCall = 0;
|
||||
this.scheduledCall = undefined;
|
||||
|
@ -23,13 +31,13 @@ module.exports = function(f, minIntervalMs) {
|
|||
var now = Date.now();
|
||||
|
||||
if (self.lastCall < now - minIntervalMs) {
|
||||
f.apply(this, arguments);
|
||||
f.apply(this);
|
||||
self.lastCall = now;
|
||||
} else if (self.scheduledCall === undefined) {
|
||||
self.scheduledCall = setTimeout(
|
||||
() => {
|
||||
self.scheduledCall = undefined;
|
||||
f.apply(this, arguments);
|
||||
f.apply(this);
|
||||
self.lastCall = now;
|
||||
},
|
||||
(self.lastCall + minIntervalMs) - now
|
||||
|
|
Loading…
Reference in a new issue