@100mslive/roomkit-react 0.3.12-alpha.6 → 0.3.12-alpha.8

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,6 +1,6 @@
1
1
  import React, { useEffect, useRef, useState } from 'react';
2
2
  import {
3
- selectLocalPeerID,
3
+ selectLocalPeer,
4
4
  selectPeerNameByID,
5
5
  selectPermissions,
6
6
  selectPollByID,
@@ -31,7 +31,9 @@ export const Voting = ({ id, toggleVoting }: { id: string; toggleVoting: () => v
31
31
  const showSingleView = poll?.type === 'quiz' && poll.state === 'started';
32
32
  const fetchedInitialResponses = useRef(false);
33
33
  const [savedResponses, setSavedResponses] = useState<Record<any, any>>({});
34
- const localPeerId = useHMSStore(selectLocalPeerID);
34
+ const localPeer = useHMSStore(selectLocalPeer);
35
+ const localPeerId = localPeer?.id;
36
+ const customerUserId = localPeer?.customerUserId;
35
37
 
36
38
  // To reset whenever a different poll is opened
37
39
  useEffect(() => {
@@ -51,7 +53,7 @@ export const Voting = ({ id, toggleVoting }: { id: string; toggleVoting: () => v
51
53
 
52
54
  useEffect(() => {
53
55
  if (poll?.questions) {
54
- const localPeerResponses = getPeerResponses(poll.questions, localPeerId);
56
+ const localPeerResponses = getPeerResponses(poll.questions, localPeerId, customerUserId);
55
57
  // @ts-ignore
56
58
  localPeerResponses?.forEach(response => {
57
59
  if (response) {
@@ -63,7 +65,7 @@ export const Voting = ({ id, toggleVoting }: { id: string; toggleVoting: () => v
63
65
  }
64
66
  });
65
67
  }
66
- }, [localPeerId, poll?.questions, id]);
68
+ }, [localPeerId, poll?.questions, id, customerUserId]);
67
69
 
68
70
  if (!poll) {
69
71
  return null;
@@ -43,18 +43,19 @@ export const ContentHeader = ({ onBack, onClose, title = '', content }) => {
43
43
  css={{ w: '100%', py: '$8', px: '$10', cursor: 'pointer', borderBottom: '1px solid $border_bright', mb: '$8' }}
44
44
  >
45
45
  {onBack ? (
46
- <Text
46
+ <Flex
47
+ align="center"
47
48
  css={{
48
- alignSelf: 'center',
49
49
  mr: '$8',
50
+ color: '$on_surface_high',
50
51
  }}
51
52
  onClick={onBack}
52
53
  data-testid="go_back"
53
54
  >
54
55
  <ChevronLeftIcon />
55
- </Text>
56
+ </Flex>
56
57
  ) : null}
57
- <Box css={{ flex: '1 1 0' }}>
58
+ <Box css={{ flex: '1 1 0', display: 'flex', alignItems: 'center' }}>
58
59
  {title ? (
59
60
  <Text
60
61
  variant="tiny"
@@ -1,4 +1,5 @@
1
- import React, { useEffect, useState } from 'react';
1
+ import React, { useEffect, useRef, useState } from 'react';
2
+ import Draggable from 'react-draggable';
2
3
  import { useMedia } from 'react-use';
3
4
  import {
4
5
  HMSTranscript,
@@ -178,6 +179,8 @@ export const CaptionsViewer = () => {
178
179
 
179
180
  const isTranscriptionEnabled = useHMSStore(selectIsTranscriptionEnabled);
180
181
 
182
+ const nodeRef = useRef<HTMLDivElement>(null);
183
+
181
184
  useEffect(() => {
182
185
  const timeInterval = setInterval(() => {
183
186
  if (!captionQueue) {
@@ -205,30 +208,33 @@ export const CaptionsViewer = () => {
205
208
  return null;
206
209
  }
207
210
  return (
208
- <Box
209
- css={{
210
- position: 'absolute',
211
- w: isMobile ? '100%' : '40%',
212
- bottom: showCaptionAtTop ? '' : '0',
213
- top: showCaptionAtTop ? '0' : '',
214
- left: isMobile ? 0 : '50%',
215
- transform: isMobile ? '' : 'translateX(-50%)',
216
- background: '#000000A3',
217
- overflow: 'clip',
218
- zIndex: 10,
219
- height: 'fit-content',
220
- r: '$1',
221
- p: '$6',
222
- transition: 'bottom 0.3s ease-in-out',
223
- '&:empty': { display: 'none' },
224
- }}
225
- >
226
- <Flex direction="column">
227
- {dataToShow.map((data: { [key: string]: string }, index: number) => {
228
- const key = Object.keys(data)[0];
229
- return <TranscriptView key={index} peer_id={key} data={data[key]} />;
230
- })}
231
- </Flex>
232
- </Box>
211
+ <Draggable bounds="parent" nodeRef={nodeRef} defaultPosition={{ x: isMobile ? 0 : -200, y: 0 }}>
212
+ <Box
213
+ ref={nodeRef}
214
+ css={{
215
+ position: 'absolute',
216
+ w: isMobile ? '100%' : '40%',
217
+ bottom: showCaptionAtTop ? '' : '0',
218
+ top: showCaptionAtTop ? '0' : '',
219
+ left: isMobile ? 0 : '50%',
220
+ transform: isMobile ? '' : 'translateX(-50%)',
221
+ background: '#000000A3',
222
+ overflow: 'clip',
223
+ zIndex: 10,
224
+ height: 'fit-content',
225
+ r: '$1',
226
+ p: '$6',
227
+ transition: 'bottom 0.3s ease-in-out',
228
+ '&:empty': { display: 'none' },
229
+ }}
230
+ >
231
+ <Flex direction="column">
232
+ {dataToShow.map((data: { [key: string]: string }, index: number) => {
233
+ const key = Object.keys(data)[0];
234
+ return <TranscriptView key={index} peer_id={key} data={data[key]} />;
235
+ })}
236
+ </Flex>
237
+ </Box>
238
+ </Draggable>
233
239
  );
234
240
  };