Rate limit UI updates to avoid browser death
This commit is contained in:
parent
15fec7f27c
commit
f035b8c50e
|
@ -20,6 +20,7 @@ var React = require('react');
|
||||||
var sdk = require('matrix-react-sdk')
|
var sdk = require('matrix-react-sdk')
|
||||||
var dis = require('matrix-react-sdk/lib/dispatcher');
|
var dis = require('matrix-react-sdk/lib/dispatcher');
|
||||||
var MatrixClientPeg = require("matrix-react-sdk/lib/MatrixClientPeg");
|
var MatrixClientPeg = require("matrix-react-sdk/lib/MatrixClientPeg");
|
||||||
|
var rate_limited_func = require('matrix-react-sdk/lib/ratelimitedfunc');
|
||||||
|
|
||||||
module.exports = React.createClass({
|
module.exports = React.createClass({
|
||||||
displayName: 'RightPanel',
|
displayName: 'RightPanel',
|
||||||
|
@ -66,15 +67,19 @@ module.exports = React.createClass({
|
||||||
onRoomStateMember: function(ev, state, member) {
|
onRoomStateMember: function(ev, state, member) {
|
||||||
// redraw the badge on the membership list
|
// redraw the badge on the membership list
|
||||||
if (this.state.phase == this.Phase.MemberList && member.roomId === this.props.roomId) {
|
if (this.state.phase == this.Phase.MemberList && member.roomId === this.props.roomId) {
|
||||||
this.forceUpdate();
|
this._delayedUpdate();
|
||||||
}
|
}
|
||||||
else if (this.state.phase === this.Phase.MemberInfo && member.roomId === this.props.roomId &&
|
else if (this.state.phase === this.Phase.MemberInfo && member.roomId === this.props.roomId &&
|
||||||
member.userId === this.state.member.userId) {
|
member.userId === this.state.member.userId) {
|
||||||
// refresh the member info (e.g. new power level)
|
// refresh the member info (e.g. new power level)
|
||||||
this.forceUpdate();
|
this._delayedUpdate();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
_delayedUpdate: new rate_limited_func(function() {
|
||||||
|
this.forceUpdate()
|
||||||
|
}, 500),
|
||||||
|
|
||||||
onAction: function(payload) {
|
onAction: function(payload) {
|
||||||
if (payload.action === "view_user") {
|
if (payload.action === "view_user") {
|
||||||
if (payload.member) {
|
if (payload.member) {
|
||||||
|
|
Loading…
Reference in New Issue