@100mslive/roomkit-react 0.2.7-alpha.2 → 0.2.7-alpha.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -4,9 +4,11 @@ import {
4
4
  HMSNotificationTypes,
5
5
  HMSRoleChangeRequest,
6
6
  HMSRoomState,
7
+ selectIsLocalScreenShared,
7
8
  selectLocalPeerID,
8
9
  selectPeerNameByID,
9
10
  selectRoomState,
11
+ useAwayNotifications,
10
12
  useCustomEvent,
11
13
  useHMSNotifications,
12
14
  useHMSStore,
@@ -14,7 +16,7 @@ import {
14
16
  } from '@100mslive/react-sdk';
15
17
  import { GroupIcon } from '@100mslive/react-icons';
16
18
  import { Box, Button } from '../../..';
17
- import { useUpdateRoomLayout } from '../../provider/roomLayoutProvider';
19
+ import { useRoomLayout, useUpdateRoomLayout } from '../../provider/roomLayoutProvider';
18
20
  // @ts-ignore: No implicit Any
19
21
  import { ToastManager } from '../Toast/ToastManager';
20
22
  import { AutoplayBlockedModal } from './AutoplayBlockedModal';
@@ -39,13 +41,16 @@ const pollToastKey: Record<string, string> = {};
39
41
  export function Notifications() {
40
42
  const localPeerID = useHMSStore(selectLocalPeerID);
41
43
  const notification = useHMSNotifications();
42
- const subscribedNotifications = useSubscribedNotifications();
44
+ const subscribedNotifications = useSubscribedNotifications() || {};
43
45
  const roomState = useHMSStore(selectRoomState);
44
46
  const updateRoomLayoutForRole = useUpdateRoomLayout();
45
47
  const isNotificationDisabled = useIsNotificationDisabled();
46
48
  const screenProps = useRoomLayoutConferencingScreen();
47
49
  const vanillaStore = useHMSVanillaStore();
48
50
  const togglePollView = usePollViewToggle();
51
+ const { showNotification } = useAwayNotifications();
52
+ const amIScreenSharing = useHMSStore(selectIsLocalScreenShared);
53
+ const logoURL = useRoomLayout()?.logo?.url;
49
54
 
50
55
  const handleRoleChangeDenied = useCallback((request: HMSRoleChangeRequest & { peerName: string }) => {
51
56
  ToastManager.addToast({
@@ -165,6 +170,14 @@ export function Notifications() {
165
170
  delete pollToastKey[notification?.data.id];
166
171
  }
167
172
  break;
173
+ case HMSNotificationTypes.NEW_MESSAGE:
174
+ if (amIScreenSharing) {
175
+ showNotification(`New message from ${notification.data.senderName}`, {
176
+ body: notification.data.message,
177
+ icon: logoURL,
178
+ });
179
+ }
180
+ break;
168
181
  default:
169
182
  break;
170
183
  }
@@ -1,5 +1,5 @@
1
1
  import React, { Fragment } from 'react';
2
- import { selectIsAllowedToPublish, useHMSStore, useScreenShare } from '@100mslive/react-sdk';
2
+ import { selectIsAllowedToPublish, useAwayNotifications, useHMSStore, useScreenShare } from '@100mslive/react-sdk';
3
3
  import { ShareScreenIcon } from '@100mslive/react-icons';
4
4
  import { ShareScreenOptions } from './pdfAnnotator/shareScreenOptions';
5
5
  import { Box, Flex } from '../../Layout';
@@ -14,6 +14,7 @@ export const ScreenshareToggle = ({ css = {} }) => {
14
14
  const isAudioOnly = useUISettings(UI_SETTINGS.isAudioOnly);
15
15
 
16
16
  const { amIScreenSharing, screenShareVideoTrackId: video, toggleScreenShare } = useScreenShare();
17
+ const { requestPermission } = useAwayNotifications();
17
18
  const isVideoScreenshare = amIScreenSharing && !!video;
18
19
  if (!isAllowedToPublish.screen || !isScreenshareSupported()) {
19
20
  return null;
@@ -28,8 +29,9 @@ export const ScreenshareToggle = ({ css = {} }) => {
28
29
  active={!isVideoScreenshare}
29
30
  css={css}
30
31
  disabled={isAudioOnly}
31
- onClick={() => {
32
- toggleScreenShare();
32
+ onClick={async () => {
33
+ await toggleScreenShare();
34
+ await requestPermission();
33
35
  }}
34
36
  >
35
37
  <Tooltip title={`${!isVideoScreenshare ? 'Start' : 'Stop'} screen sharing`}>