@100mslive/roomkit-react 0.2.6-alpha.1 → 0.2.6-alpha.3

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,9 +1,9 @@
1
1
  import React, { useEffect, useMemo, useRef, useState } from 'react';
2
2
  import {
3
- HMSPoll,
4
3
  HMSPollState,
5
4
  selectLocalPeerRoleName,
6
5
  selectPermissions,
6
+ selectPolls,
7
7
  useHMSActions,
8
8
  useHMSStore,
9
9
  } from '@100mslive/react-sdk';
@@ -133,7 +133,7 @@ const AddMenu = () => {
133
133
  active={interactionType === INTERACTION_TYPE.QUIZ}
134
134
  />
135
135
  </Flex>
136
- <Flex direction="column">
136
+ <Flex direction="column" css={{ mb: '$10' }}>
137
137
  <Text variant="body2" css={{ mb: '$4' }}>{`Name this ${interactionType.toLowerCase()}`}</Text>
138
138
  <Input
139
139
  ref={inputRef}
@@ -194,20 +194,12 @@ const AddMenu = () => {
194
194
 
195
195
  const PrevMenu = () => {
196
196
  const hmsActions = useHMSActions();
197
- const [polls, setPolls] = useState<HMSPoll[]>([]);
197
+ const polls = useHMSStore(selectPolls);
198
+ const permissions = useHMSStore(selectPermissions);
198
199
 
199
200
  useEffect(() => {
200
- const listPolls = async () => {
201
- const polls = await hmsActions.interactivityCenter.getPolls();
202
- const sortedPolls = await polls
203
- ?.sort((a, b) => (b.createdAt?.getTime() || 0) - (a.createdAt?.getTime() || 0))
204
- ?.sort((a, b) => (b.state === 'started' ? 1 : 0) - (a.state === 'started' ? 1 : 0));
205
- return sortedPolls;
206
- };
207
-
208
201
  const updatePolls = async () => {
209
- const sortedPolls = await listPolls();
210
- setPolls(sortedPolls);
202
+ await hmsActions.interactivityCenter.getPolls();
211
203
  };
212
204
 
213
205
  updatePolls();
@@ -215,21 +207,19 @@ const PrevMenu = () => {
215
207
 
216
208
  return polls?.length ? (
217
209
  <Flex
210
+ direction="column"
218
211
  css={{
219
- borderTop: '$space$px solid $border_bright',
220
- mt: '$10',
221
- pt: '$10',
212
+ width: '100%',
213
+ ...(permissions?.pollWrite ? { borderTop: '$space$px solid $border_bright', paddingTop: '$10' } : {}),
222
214
  }}
223
215
  >
224
- <Flex direction="column" css={{ w: '100%' }}>
225
- <Text variant="h6" css={{ c: '$on_surface_high' }}>
226
- Previous Polls and Quizzes
227
- </Text>
228
- <Flex direction="column" css={{ gap: '$10', mt: '$8' }}>
229
- {polls?.map(poll => (
230
- <InteractionCard key={poll.id} id={poll.id} title={poll.title} status={poll.state} />
231
- ))}
232
- </Flex>
216
+ <Text variant="h6" css={{ c: '$on_surface_high' }}>
217
+ Previous Polls and Quizzes
218
+ </Text>
219
+ <Flex direction="column" css={{ gap: '$10', mt: '$8' }}>
220
+ {polls?.map(poll => (
221
+ <InteractionCard key={poll.id} id={poll.id} title={poll.title} status={poll.state} />
222
+ ))}
233
223
  </Flex>
234
224
  </Flex>
235
225
  ) : null;
@@ -54,7 +54,7 @@ export const LeaderboardEntry = ({
54
54
  </Flex>
55
55
 
56
56
  <Flex align="center" css={{ gap: '$4', color: '$on_surface_medium' }}>
57
- {position === 1 ? <TrophyFilledIcon height={16} width={16} /> : null}
57
+ {position === 1 && score ? <TrophyFilledIcon height={16} width={16} /> : null}
58
58
  {questionCount ? (
59
59
  <>
60
60
  <CheckCircleIcon height={16} width={16} />
@@ -103,7 +103,6 @@ const PreviewJoin = ({
103
103
  asRole,
104
104
  });
105
105
  const roomState = useHMSStore(selectRoomState);
106
-
107
106
  const savePreferenceAndJoin = useCallback(() => {
108
107
  setPreviewPreference({
109
108
  name,
@@ -1,5 +1,10 @@
1
1
  import React, { useEffect, useState } from 'react';
2
- import { selectEffectsKey, selectIsEffectsEnabled, selectLocalPeerRole } from '@100mslive/hms-video-store';
2
+ import {
3
+ selectAppData,
4
+ selectEffectsKey,
5
+ selectIsEffectsEnabled,
6
+ selectLocalPeerRole,
7
+ } from '@100mslive/hms-video-store';
3
8
  import { HMSEffectsPlugin, HMSVBPlugin, HMSVirtualBackgroundTypes } from '@100mslive/hms-virtual-background';
4
9
  import { VirtualBackgroundMedia } from '@100mslive/types-prebuilt/elements/virtual_background';
5
10
  import {
@@ -22,7 +27,7 @@ import { VBHandler } from './VBHandler';
22
27
  import { useSidepaneToggle } from '../AppData/useSidepane';
23
28
  // @ts-ignore
24
29
  import { useUISettings } from '../AppData/useUISettings';
25
- import { SIDE_PANE_OPTIONS, UI_SETTINGS } from '../../common/constants';
30
+ import { APP_DATA, SIDE_PANE_OPTIONS, UI_SETTINGS } from '../../common/constants';
26
31
  import { defaultMedia } from './constants';
27
32
 
28
33
  const iconDims = { height: '40px', width: '40px' };
@@ -42,9 +47,7 @@ export const VBPicker = ({ backgroundMedia = [] }: { backgroundMedia: VirtualBac
42
47
  const isEffectsEnabled = useHMSStore(selectIsEffectsEnabled);
43
48
  const effectsKey = useHMSStore(selectEffectsKey);
44
49
  const isPluginAdded = useHMSStore(selectIsLocalVideoPluginPresent(VBHandler?.getName() || ''));
45
- const [activeBackground, setActiveBackground] = useState<string | HMSVirtualBackgroundTypes>(
46
- (VBHandler?.getBackground() as string | HMSVirtualBackgroundTypes) || HMSVirtualBackgroundTypes.NONE,
47
- );
50
+ const background = useHMSStore(selectAppData(APP_DATA.background));
48
51
  const mediaList = backgroundMedia.length
49
52
  ? backgroundMedia.map((media: VirtualBackgroundMedia) => media.url || '')
50
53
  : defaultMedia;
@@ -71,8 +74,22 @@ export const VBPicker = ({ backgroundMedia = [] }: { backgroundMedia: VirtualBac
71
74
  hmsActions.addPluginToVideoTrack(vbObject as HMSVBPlugin, Math.floor(role.publishParams.video.frameRate / 2));
72
75
  }
73
76
  }
77
+ const handleDefaultBackground = async () => {
78
+ switch (background) {
79
+ case HMSVirtualBackgroundTypes.NONE: {
80
+ break;
81
+ }
82
+ case HMSVirtualBackgroundTypes.BLUR: {
83
+ await VBHandler.setBlur(blurAmount);
84
+ break;
85
+ }
86
+ default:
87
+ await VBHandler.setBackground(background);
88
+ }
89
+ };
90
+ handleDefaultBackground();
74
91
  }
75
- }, [hmsActions, role, isPluginAdded, isEffectsEnabled, effectsKey, track?.id]);
92
+ }, [hmsActions, role, isPluginAdded, isEffectsEnabled, effectsKey, track?.id, background, blurAmount]);
76
93
 
77
94
  useEffect(() => {
78
95
  if (!isVideoOn) {
@@ -120,7 +137,7 @@ export const VBPicker = ({ backgroundMedia = [] }: { backgroundMedia: VirtualBac
120
137
  value: HMSVirtualBackgroundTypes.NONE,
121
138
  onClick: async () => {
122
139
  await VBHandler.removeEffects();
123
- setActiveBackground(HMSVirtualBackgroundTypes.NONE);
140
+ hmsActions.setAppData(APP_DATA.background, HMSVirtualBackgroundTypes.NONE);
124
141
  },
125
142
  },
126
143
  {
@@ -129,16 +146,16 @@ export const VBPicker = ({ backgroundMedia = [] }: { backgroundMedia: VirtualBac
129
146
  value: HMSVirtualBackgroundTypes.BLUR,
130
147
  onClick: async () => {
131
148
  await VBHandler?.setBlur(blurAmount);
132
- setActiveBackground(HMSVirtualBackgroundTypes.BLUR);
149
+ hmsActions.setAppData(APP_DATA.background, HMSVirtualBackgroundTypes.BLUR);
133
150
  },
134
151
  },
135
152
  ]}
136
- activeBackground={activeBackground}
153
+ activeBackground={background}
137
154
  />
138
155
 
139
156
  {/* Slider */}
140
157
  <Flex direction="column" css={{ w: '100%', gap: '$8', mt: '$8' }}>
141
- {activeBackground === HMSVirtualBackgroundTypes.BLUR && isEffectsEnabled && effectsKey ? (
158
+ {background === HMSVirtualBackgroundTypes.BLUR && isEffectsEnabled && effectsKey ? (
142
159
  <Box>
143
160
  <Text variant="sm" css={{ color: '$on_surface_high', fontWeight: '$semiBold', mb: '$4' }}>
144
161
  Blur intensity
@@ -173,10 +190,10 @@ export const VBPicker = ({ backgroundMedia = [] }: { backgroundMedia: VirtualBac
173
190
  value: mediaURL,
174
191
  onClick: async () => {
175
192
  await VBHandler?.setBackground(mediaURL);
176
- setActiveBackground(mediaURL);
193
+ hmsActions.setAppData(APP_DATA.background, mediaURL);
177
194
  },
178
195
  }))}
179
- activeBackground={activeBackground}
196
+ activeBackground={background}
180
197
  />
181
198
  </Box>
182
199
  </Flex>