Fix bug where vector freezes on power level event
Make rate_limited_function accept functions with args so we can just ratelimit the event handler & be done with it. Fixes https://github.com/vector-im/vector-web/issues/1877
This commit is contained in:
parent
4b763997df
commit
4ecf5f6372
2 changed files with 6 additions and 4 deletions
|
@ -23,13 +23,13 @@ module.exports = function(f, minIntervalMs) {
|
|||
var now = Date.now();
|
||||
|
||||
if (self.lastCall < now - minIntervalMs) {
|
||||
f.apply(this);
|
||||
f.apply(this, arguments);
|
||||
self.lastCall = now;
|
||||
} else if (self.scheduledCall === undefined) {
|
||||
self.scheduledCall = setTimeout(
|
||||
() => {
|
||||
self.scheduledCall = undefined;
|
||||
f.apply(this);
|
||||
f.apply(this, arguments);
|
||||
self.lastCall = now;
|
||||
},
|
||||
(self.lastCall + minIntervalMs) - now
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue