Update transport stats only when advancedMode is on

This commit is contained in:
Roman Drozd
2020-05-20 00:12:33 +02:00
parent 014c805530
commit 3fc8f5683e
2 changed files with 29 additions and 22 deletions
-7
View File
@@ -260,9 +260,6 @@ export default class RoomClient
this._startKeyListener(); this._startKeyListener();
this._startDevicesListener(); this._startDevicesListener();
this._getTransportStats();
} }
close() close()
@@ -626,8 +623,6 @@ export default class RoomClient
async _getTransportStats() async _getTransportStats()
{ {
try try
{
setInterval(async () =>
{ {
if (this._recvTransport) if (this._recvTransport)
{ {
@@ -648,8 +643,6 @@ export default class RoomClient
store.dispatch( store.dispatch(
transportActions.addTransportStats(send, 'send')); transportActions.addTransportStats(send, 'send'));
} }
}, 1000);
} }
catch (error) catch (error)
{ {
+15 -1
View File
@@ -1,4 +1,4 @@
import React, { useState } from 'react'; import React, { useState, useEffect } from 'react';
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import { import {
meProducersSelector, meProducersSelector,
@@ -334,6 +334,20 @@ const Me = (props) =>
); );
} }
useEffect(() =>
{
let poll;
const interval = 1000;
if (advancedMode)
{
poll = setInterval(() => roomClient._getTransportStats(), interval);
}
return () => clearInterval(poll);
}, [ roomClient, advancedMode ]);
return ( return (
<React.Fragment> <React.Fragment>
<div <div