@100mslive/roomkit-react 0.3.12-alpha.0 → 0.3.12-alpha.2

Sign up to get free protection for your applications and to get access to all the features.
package/package.json CHANGED
@@ -10,7 +10,7 @@
10
10
  "prebuilt",
11
11
  "roomkit"
12
12
  ],
13
- "version": "0.3.12-alpha.0",
13
+ "version": "0.3.12-alpha.2",
14
14
  "author": "100ms",
15
15
  "license": "MIT",
16
16
  "repository": {
@@ -74,12 +74,12 @@
74
74
  "react": ">=17.0.2 <19.0.0"
75
75
  },
76
76
  "dependencies": {
77
- "@100mslive/hls-player": "0.3.12-alpha.0",
77
+ "@100mslive/hls-player": "0.3.12-alpha.2",
78
78
  "@100mslive/hms-noise-cancellation": "0.0.1",
79
- "@100mslive/hms-virtual-background": "1.13.12-alpha.0",
80
- "@100mslive/hms-whiteboard": "0.0.2-alpha.0",
81
- "@100mslive/react-icons": "0.10.12-alpha.0",
82
- "@100mslive/react-sdk": "0.10.12-alpha.0",
79
+ "@100mslive/hms-virtual-background": "1.13.12-alpha.2",
80
+ "@100mslive/hms-whiteboard": "0.0.2-alpha.2",
81
+ "@100mslive/react-icons": "0.10.12-alpha.2",
82
+ "@100mslive/react-sdk": "0.10.12-alpha.2",
83
83
  "@100mslive/types-prebuilt": "0.12.8",
84
84
  "@emoji-mart/data": "^1.0.6",
85
85
  "@emoji-mart/react": "^1.0.1",
@@ -115,5 +115,5 @@
115
115
  "uuid": "^8.3.2",
116
116
  "worker-timers": "^7.0.40"
117
117
  },
118
- "gitHead": "5e32c0c62aba5aa7786a01912511da6ac33461a2"
118
+ "gitHead": "661d33178068de7f764ef7b31119b04c12c22176"
119
119
  }
@@ -89,12 +89,11 @@ export const CaptionContent = ({ isMobile, onExit }: { isMobile: boolean; onExit
89
89
  data-testid="popup_change_btn"
90
90
  onClick={async () => {
91
91
  try {
92
- ToastManager.removeToast(toastId);
93
92
  if (isTranscriptionEnabled) {
94
93
  await actions.stopTranscription({
95
94
  mode: HMSTranscriptionMode.CAPTION,
96
95
  });
97
- const id = ToastManager.addToast({
96
+ const id = ToastManager.replaceToast(toastId, {
98
97
  title: `Disabling Closed Caption for everyone.`,
99
98
  variant: 'standard',
100
99
  duration: DURATION,
@@ -107,7 +106,7 @@ export const CaptionContent = ({ isMobile, onExit }: { isMobile: boolean; onExit
107
106
  await actions.startTranscription({
108
107
  mode: HMSTranscriptionMode.CAPTION,
109
108
  });
110
- const id = ToastManager.addToast({
109
+ const id = ToastManager.replaceToast(toastId, {
111
110
  title: `Enabling Closed Caption for everyone.`,
112
111
  variant: 'standard',
113
112
  duration: DURATION,
@@ -115,7 +114,7 @@ export const CaptionContent = ({ isMobile, onExit }: { isMobile: boolean; onExit
115
114
  });
116
115
  setToastId(id);
117
116
  } catch (err) {
118
- const id = ToastManager.addToast({
117
+ const id = ToastManager.replaceToast(toastId, {
119
118
  title: `Failed to ${isTranscriptionEnabled ? 'disabled' : 'enabled'} closed caption`,
120
119
  variant: 'error',
121
120
  icon: <AlertTriangleIcon style={{ marginRight: '0.5rem' }} />,
@@ -1,11 +1,9 @@
1
1
  /* eslint-disable no-case-declarations */
2
2
  import React, { useCallback, useEffect } from 'react';
3
- import { match } from 'ts-pattern';
4
3
  import {
5
4
  HMSNotificationTypes,
6
5
  HMSRoleChangeRequest,
7
6
  HMSRoomState,
8
- HMSTranscriptionState,
9
7
  selectIsLocalScreenShared,
10
8
  selectLocalPeerID,
11
9
  selectPeerNameByID,
@@ -16,7 +14,7 @@ import {
16
14
  useHMSStore,
17
15
  useHMSVanillaStore,
18
16
  } from '@100mslive/react-sdk';
19
- import { AlertTriangleIcon, ClosedCaptionIcon, GroupIcon, OpenCaptionIcon } from '@100mslive/react-icons';
17
+ import { GroupIcon } from '@100mslive/react-icons';
20
18
  import { Box, Button } from '../../..';
21
19
  import { useRoomLayout, useUpdateRoomLayout } from '../../provider/roomLayoutProvider';
22
20
  // @ts-ignore: No implicit Any
@@ -31,12 +29,13 @@ import { ReconnectNotifications } from './ReconnectNotifications';
31
29
  import { TrackBulkUnmuteModal } from './TrackBulkUnmuteModal';
32
30
  import { TrackNotifications } from './TrackNotifications';
33
31
  import { TrackUnmuteModal } from './TrackUnmuteModal';
32
+ import { TranscriptionNotifications } from './TranscriptionNotifications';
34
33
  import { useRoomLayoutConferencingScreen } from '../../provider/roomLayoutProvider/hooks/useRoomLayoutScreen';
35
34
  // @ts-ignore: No implicit Any
36
35
  import { usePollViewToggle } from '../AppData/useSidepane';
37
36
  // @ts-ignore: No implicit Any
38
- import { useIsNotificationDisabled, useSetAppDataByKey, useSubscribedNotifications } from '../AppData/useUISettings';
39
- import { CAPTION_TOAST, ROLE_CHANGE_DECLINED } from '../../common/constants';
37
+ import { useIsNotificationDisabled, useSubscribedNotifications } from '../AppData/useUISettings';
38
+ import { ROLE_CHANGE_DECLINED } from '../../common/constants';
40
39
 
41
40
  const pollToastKey: Record<string, string> = {};
42
41
 
@@ -53,7 +52,6 @@ export function Notifications() {
53
52
  const { showNotification } = useAwayNotifications();
54
53
  const amIScreenSharing = useHMSStore(selectIsLocalScreenShared);
55
54
  const logoURL = useRoomLayout()?.logo?.url;
56
- const [toastId, setToastId] = useSetAppDataByKey(CAPTION_TOAST.captionToast);
57
55
 
58
56
  const handleRoleChangeDenied = useCallback((request: HMSRoleChangeRequest & { peerName: string }) => {
59
57
  ToastManager.addToast({
@@ -181,44 +179,6 @@ export function Notifications() {
181
179
  });
182
180
  }
183
181
  break;
184
- case HMSNotificationTypes.TRANSCRIPTION_STATE_UPDATED:
185
- const transcriptionStates = notification.data;
186
- if (transcriptionStates && transcriptionStates.length > 0) {
187
- let id = '';
188
- match({ state: transcriptionStates[0].state, error: transcriptionStates[0].error })
189
- .when(
190
- ({ error }) => !!error,
191
- () => {
192
- ToastManager.removeToast(toastId);
193
- id = ToastManager.addToast({
194
- title: `Failed to enable Closed Caption`,
195
- variant: 'error',
196
- icon: <AlertTriangleIcon style={{ marginRight: '0.5rem' }} />,
197
- });
198
- },
199
- )
200
- .with({ state: HMSTranscriptionState.STARTED }, () => {
201
- ToastManager.removeToast(toastId);
202
- id = ToastManager.addToast({
203
- title: `Closed Captioning enabled for everyone`,
204
- variant: 'standard',
205
- duration: 2000,
206
- icon: <OpenCaptionIcon style={{ marginRight: '0.5rem' }} />,
207
- });
208
- })
209
- .with({ state: HMSTranscriptionState.STOPPED }, () => {
210
- ToastManager.removeToast(toastId);
211
- id = ToastManager.addToast({
212
- title: `Closed Captioning disabled for everyone`,
213
- variant: 'standard',
214
- duration: 2000,
215
- icon: <ClosedCaptionIcon style={{ marginRight: '0.5rem' }} />,
216
- });
217
- })
218
- .otherwise(() => null);
219
- setToastId(id);
220
- }
221
- break;
222
182
  default:
223
183
  break;
224
184
  }
@@ -241,6 +201,7 @@ export function Notifications() {
241
201
  <InitErrorModal />
242
202
  <ChatNotifications />
243
203
  <HandRaisedNotifications />
204
+ <TranscriptionNotifications />
244
205
  </>
245
206
  );
246
207
  }
@@ -0,0 +1,58 @@
1
+ import React, { useEffect } from 'react';
2
+ import { match } from 'ts-pattern';
3
+ import { HMSNotificationTypes, HMSTranscriptionState, useHMSNotifications } from '@100mslive/react-sdk';
4
+ import { AlertTriangleIcon, ClosedCaptionIcon, OpenCaptionIcon } from '@100mslive/react-icons';
5
+ // @ts-ignore: No implicit Any
6
+ import { ToastManager } from '../Toast/ToastManager';
7
+ // @ts-ignore: No implicit Any
8
+ import { useSetAppDataByKey } from '../AppData/useUISettings';
9
+ import { CAPTION_TOAST } from '../../common/constants';
10
+
11
+ export const TranscriptionNotifications = () => {
12
+ const notification = useHMSNotifications(HMSNotificationTypes.TRANSCRIPTION_STATE_UPDATED);
13
+ const [toastId, setToastId] = useSetAppDataByKey(CAPTION_TOAST.captionToast);
14
+
15
+ useEffect(() => {
16
+ if (!notification?.data) {
17
+ return;
18
+ }
19
+
20
+ console.debug(`[${notification.type}]`, notification);
21
+ const transcriptionStates = notification.data;
22
+ if (transcriptionStates.length > 0) {
23
+ let id = '';
24
+ match({ state: transcriptionStates[0].state, error: transcriptionStates[0].error })
25
+ .when(
26
+ ({ error }) => !!error,
27
+ () => {
28
+ id = ToastManager.replaceToast(toastId, {
29
+ title: `Failed to enable Closed Caption`,
30
+ variant: 'error',
31
+ icon: <AlertTriangleIcon style={{ marginRight: '0.5rem' }} />,
32
+ });
33
+ },
34
+ )
35
+ .with({ state: HMSTranscriptionState.STARTED }, () => {
36
+ id = ToastManager.replaceToast(toastId, {
37
+ title: `Closed Captioning enabled for everyone`,
38
+ variant: 'standard',
39
+ duration: 2000,
40
+ icon: <OpenCaptionIcon style={{ marginRight: '0.5rem' }} />,
41
+ });
42
+ })
43
+ .with({ state: HMSTranscriptionState.STOPPED }, () => {
44
+ id = ToastManager.replaceToast(toastId, {
45
+ title: `Closed Captioning disabled for everyone`,
46
+ variant: 'standard',
47
+ duration: 2000,
48
+ icon: <ClosedCaptionIcon style={{ marginRight: '0.5rem' }} />,
49
+ });
50
+ })
51
+ .otherwise(() => null);
52
+ setToastId(id);
53
+ }
54
+ // eslint-disable-next-line react-hooks/exhaustive-deps
55
+ }, [notification, setToastId]);
56
+
57
+ return null;
58
+ };