@100mslive/roomkit-react 0.3.25 → 0.3.26

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,7 +1,14 @@
1
1
  // @ts-check
2
2
  import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react';
3
3
  import { match } from 'ts-pattern';
4
- import { selectLocalPeer, selectLocalPeerRoleName, useHMSActions, useHMSStore } from '@100mslive/react-sdk';
4
+ import {
5
+ HMSRoomState,
6
+ selectLocalPeer,
7
+ selectLocalPeerRoleName,
8
+ selectRoomState,
9
+ useHMSActions,
10
+ useHMSStore,
11
+ } from '@100mslive/react-sdk';
5
12
  import { CheckCircleIcon, ChevronDownIcon, CrossCircleIcon } from '@100mslive/react-icons';
6
13
  import { Box, Button, Flex, Text } from '../../../../';
7
14
  import { checkCorrectAnswer } from '../../../common/utils';
@@ -27,7 +34,7 @@ export const QuestionCard = ({
27
34
  }) => {
28
35
  const actions = useHMSActions();
29
36
  const localPeer = useHMSStore(selectLocalPeer);
30
-
37
+ const roomState = useHMSStore(selectRoomState);
31
38
  const isLocalPeerCreator = localPeer?.id === startedBy;
32
39
  const localPeerRoleName = useHMSStore(selectLocalPeerRoleName);
33
40
  const roleCanViewResponse =
@@ -183,13 +190,19 @@ export const QuestionCard = ({
183
190
  ) : null}
184
191
  </Box>
185
192
  {isLive && (
186
- <QuestionActions isValidVote={isValidVote} onVote={handleVote} response={localPeerChoice} isQuiz={isQuiz} />
193
+ <QuestionActions
194
+ disableVote={roomState !== HMSRoomState.Connected}
195
+ isValidVote={isValidVote}
196
+ onVote={handleVote}
197
+ response={localPeerChoice}
198
+ isQuiz={isQuiz}
199
+ />
187
200
  )}
188
201
  </Box>
189
202
  );
190
203
  };
191
204
 
192
- const QuestionActions = ({ isValidVote, response, isQuiz, onVote }) => {
205
+ const QuestionActions = ({ isValidVote, response, isQuiz, onVote, disableVote }) => {
193
206
  return (
194
207
  <Flex align="center" justify="end" css={{ gap: '$4', w: '100%' }}>
195
208
  {response ? (
@@ -199,7 +212,7 @@ const QuestionActions = ({ isValidVote, response, isQuiz, onVote }) => {
199
212
  {!isQuiz && !response.skipped ? 'Voted' : null}
200
213
  </Text>
201
214
  ) : (
202
- <Button css={{ p: '$xs $10', fontWeight: '$semiBold' }} disabled={!isValidVote} onClick={onVote}>
215
+ <Button css={{ p: '$xs $10', fontWeight: '$semiBold' }} disabled={!isValidVote || disableVote} onClick={onVote}>
203
216
  {isQuiz ? 'Answer' : 'Vote'}
204
217
  </Button>
205
218
  )}
@@ -275,7 +275,7 @@ const LocalPeerStats = () => {
275
275
  return (
276
276
  <Flex css={{ flexWrap: 'wrap', gap: '$10' }}>
277
277
  <StatsRow label="Packets Lost" value={stats.subscribe?.packetsLost} />
278
- <StatsRow label="Jitter" value={stats.subscribe?.jitter} />
278
+ <StatsRow label="Jitter" value={`${((stats.subscribe?.jitter ?? 0) * 1000).toFixed(2)} ms`} />
279
279
  <StatsRow label="Publish Bitrate" value={formatBytes(stats.publish?.bitrate, 'b/s')} />
280
280
  <StatsRow label="Subscribe Bitrate" value={formatBytes(stats.subscribe?.bitrate, 'b/s')} />
281
281
  <StatsRow
@@ -316,7 +316,7 @@ const TrackStats = ({ trackID, layer, local }) => {
316
316
  <StatsRow label="Type" value={stats.type + ' ' + stats.kind} />
317
317
  <StatsRow label="Bitrate" value={formatBytes(stats.bitrate, 'b/s')} />
318
318
  <StatsRow label="Packets Lost" value={stats.packetsLost} />
319
- <StatsRow label="Jitter" value={stats.jitter?.toFixed(3)} />
319
+ <StatsRow label="Jitter" value={`${((stats.subscribe?.jitter ?? 0) * 1000).toFixed(2)} ms`} />
320
320
  <StatsRow
321
321
  label={inbound ? 'Bytes Received' : 'Bytes Sent'}
322
322
  value={formatBytes(inbound ? stats.bytesReceived : stats.bytesSent)}
@@ -159,12 +159,21 @@ const PacketLostAndJitter = ({
159
159
  const isLocalPeer = audioTrackStats?.type.includes('outbound') || videoTrackStats?.type.includes('outbound');
160
160
  const audioStats = isLocalPeer ? audioTrackStats?.remote : audioTrackStats;
161
161
  const videoStats = isLocalPeer ? videoTrackStats?.remote : videoTrackStats;
162
+
162
163
  return (
163
164
  <>
164
165
  <TrackPacketsLostRow label="Packet Loss(V)" stats={videoStats} />
165
166
  <TrackPacketsLostRow label="Packet Loss(A)" stats={audioStats} />
166
- <StatsRow show={isNotNullish(videoStats?.jitter)} label="Jitter(V)" value={videoStats?.jitter?.toFixed(4)} />
167
- <StatsRow show={isNotNullish(audioStats?.jitter)} label="Jitter(A)" value={audioStats?.jitter?.toFixed(4)} />
167
+ <StatsRow
168
+ show={isNotNullish(videoStats?.jitter)}
169
+ label="Jitter(V)"
170
+ value={`${((videoStats?.jitter ?? 0) * 1000).toFixed(2)} ms`}
171
+ />
172
+ <StatsRow
173
+ show={isNotNullish(audioStats?.jitter)}
174
+ label="Jitter(A)"
175
+ value={`${((audioStats?.jitter ?? 0) * 1000).toFixed(2)} ms`}
176
+ />
168
177
  </>
169
178
  );
170
179
  };