fix: validate latency badge props
This commit is contained in:
parent
84481a4fec
commit
8e792d1658
|
|
@ -31,12 +31,12 @@ const JKLatencyBadge = ({ latencyData, showAll, showBadgeOnly }) => {
|
|||
|
||||
useEffect(() => {
|
||||
if (latencyData) {
|
||||
const tot = Math.round(latencyData.ars.internet_latency) + Math.round(latencyData.audio_latency);
|
||||
const tot = Math.round(latencyData.ars_internet_latency) + Math.round(latencyData.audio_latency);
|
||||
setLatencyLabel(tot);
|
||||
|
||||
if (showAll) {
|
||||
setLatencyInfo(
|
||||
`${Math.round(latencyData.ars.internet_latency)}ms (Internet) + ${Math.round(
|
||||
`${Math.round(latencyData.ars_internet_latency)}ms (Internet) + ${Math.round(
|
||||
latencyData.audio_latency
|
||||
)}ms (audio) = ${tot}ms (total) `
|
||||
);
|
||||
|
|
@ -57,7 +57,10 @@ const JKLatencyBadge = ({ latencyData, showAll, showBadgeOnly }) => {
|
|||
};
|
||||
|
||||
JKLatencyBadge.propTypes = {
|
||||
latencyData: PropTypes.object,
|
||||
latencyData: PropTypes.shape({
|
||||
ars_internet_latency: PropTypes.number.isRequired,
|
||||
audio_latency: PropTypes.number.isRequired
|
||||
}),
|
||||
showAll: PropTypes.bool,
|
||||
showBadgeOnly: PropTypes.bool
|
||||
};
|
||||
|
|
|
|||
|
|
@ -5,7 +5,13 @@ import PropTypes from 'prop-types';
|
|||
import JKLatencyBadge from './JKLatencyBadge';
|
||||
|
||||
const JKUserLatency = ({user, showAll, showBadgeOnly}) => {
|
||||
const latencyData = useSelector(state => state.latency.latencies.find(l => l.user_id === user.id));
|
||||
const latencyData = useSelector(state => {
|
||||
const userLatency = state.latency.latencies.find(l => l.user_id === user.id);
|
||||
return {
|
||||
ars_internet_latency: userLatency?.ars?.internet_latency,
|
||||
audio_latency: userLatency?.audio_latency
|
||||
}
|
||||
});
|
||||
return (
|
||||
<JKLatencyBadge latencyData={latencyData} showAll={showAll} showBadgeOnly={showBadgeOnly} />
|
||||
);
|
||||
|
|
|
|||
|
|
@ -10,7 +10,13 @@ import PropTypes from 'prop-types';
|
|||
|
||||
function JKSessionUser({ user }) {
|
||||
const dispatch = useDispatch();
|
||||
const latencyData = useSelector(state => state.latency.latencies.find(l => l.user_id === user.id));
|
||||
const latencyData = useSelector(state => {
|
||||
const userLatency = state.latency.latencies.find(l => l.user_id === user.id);
|
||||
return {
|
||||
ars_internet_latency: userLatency?.ars?.internet_latency,
|
||||
audio_latency: userLatency?.audio_latency
|
||||
}
|
||||
});
|
||||
const userData = useSelector(state => state.session.people.find(p => p.id === user.id));
|
||||
const [showSidePanel, setShowSidePanel] = useState(false);
|
||||
const { greaterThan } = useResponsive();
|
||||
|
|
|
|||
Loading…
Reference in New Issue