More performance tweaks

This commit is contained in:
Maciej Hirsz
2020-11-03 17:48:42 +01:00
parent 54039faa3b
commit 403b1c0fa1
3 changed files with 12 additions and 15 deletions
+8 -2
View File
@@ -97,10 +97,12 @@ export class Connection {
private pingSent: Maybe<Types.Timestamp> = null;
private resubscribeTo: Maybe<Types.ChainLabel> = getHashData().chain;
private resubscribeSendFinality: boolean = getHashData().tab === 'consensus';
private updateThrottle = false;
private socket: WebSocket;
private state: Readonly<State>;
private readonly update: Update;
private readonly pins: PersistentSet<Types.NodeName>;
constructor(
socket: WebSocket,
update: Update,
@@ -408,8 +410,12 @@ export class Connection {
}
}
if (nodes.hasChangedSince(ref)) {
this.state = this.update({ nodes });
if (nodes.hasChangedSince(ref) && !this.updateThrottle) {
this.updateThrottle = true;
window.requestAnimationFrame(() => {
this.update({ nodes });
this.updateThrottle = false;
});
}
this.autoSubscribe();