@100mslive/roomkit-react 0.1.12 → 0.1.13

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.
Files changed (68) hide show
  1. package/dist/{HLSView-PWVM4OIP.js → HLSView-IENE4HRP.js} +2 -2
  2. package/dist/Prebuilt/App.d.ts +0 -2
  3. package/dist/Prebuilt/AppContext.d.ts +0 -2
  4. package/dist/Prebuilt/common/constants.d.ts +110 -0
  5. package/dist/Prebuilt/components/AppData/AppData.d.ts +2 -0
  6. package/dist/Prebuilt/components/Chat/MwebChatOption.d.ts +7 -0
  7. package/dist/Prebuilt/components/Chat/Navigation.d.ts +8 -0
  8. package/dist/Prebuilt/components/Chat/PinnedMessage.d.ts +4 -0
  9. package/dist/Prebuilt/components/Footer/Footer.d.ts +3 -2
  10. package/dist/Prebuilt/components/Notifications/ChatNotifications.d.ts +2 -0
  11. package/dist/Prebuilt/components/Preview/PreviewJoin.d.ts +2 -1
  12. package/dist/Prebuilt/components/VirtualBackground/VBCollection.d.ts +2 -1
  13. package/dist/Prebuilt/components/VirtualBackground/VBPicker.d.ts +3 -0
  14. package/dist/Prebuilt/components/VirtualBackground/constants.d.ts +0 -6
  15. package/dist/Prebuilt/components/hooks/useChatBlacklist.d.ts +4 -0
  16. package/dist/Prebuilt/components/hooks/useSetPinnedMessages.d.ts +16 -0
  17. package/dist/Prebuilt/provider/roomLayoutProvider/hooks/useRoomLayoutScreen.d.ts +3 -2
  18. package/dist/{chunk-WREKGNP6.js → chunk-U4AB6X6M.js} +2178 -1148
  19. package/dist/chunk-U4AB6X6M.js.map +7 -0
  20. package/dist/index.cjs.js +2746 -1638
  21. package/dist/index.cjs.js.map +4 -4
  22. package/dist/index.js +1 -1
  23. package/dist/meta.cjs.json +803 -208
  24. package/dist/meta.esbuild.json +812 -217
  25. package/package.json +8 -7
  26. package/src/Prebuilt/App.tsx +3 -14
  27. package/src/Prebuilt/AppContext.tsx +0 -2
  28. package/src/Prebuilt/common/{constants.js → constants.ts} +22 -20
  29. package/src/Prebuilt/components/AppData/{AppData.jsx → AppData.tsx} +8 -22
  30. package/src/Prebuilt/components/AppData/useUISettings.js +0 -4
  31. package/src/Prebuilt/components/AuthToken.jsx +15 -5
  32. package/src/Prebuilt/components/Chat/Chat.jsx +49 -73
  33. package/src/Prebuilt/components/Chat/ChatBody.jsx +241 -51
  34. package/src/Prebuilt/components/Chat/ChatFooter.tsx +56 -6
  35. package/src/Prebuilt/components/Chat/ChatStates.jsx +68 -0
  36. package/src/Prebuilt/components/Chat/MwebChatOption.tsx +24 -0
  37. package/src/Prebuilt/components/Chat/Navigation.tsx +60 -0
  38. package/src/Prebuilt/components/Chat/PinnedMessage.tsx +116 -0
  39. package/src/Prebuilt/components/Footer/Footer.tsx +4 -7
  40. package/src/Prebuilt/components/Header/common.jsx +1 -1
  41. package/src/Prebuilt/components/Notifications/ChatNotifications.tsx +34 -0
  42. package/src/Prebuilt/components/Notifications/Notifications.tsx +2 -0
  43. package/src/Prebuilt/components/Polls/Voting/QuestionCard.jsx +6 -4
  44. package/src/Prebuilt/components/Polls/Voting/TimedVoting.jsx +3 -2
  45. package/src/Prebuilt/components/Polls/common/VoteCount.jsx +6 -4
  46. package/src/Prebuilt/components/Preview/PreviewJoin.tsx +7 -9
  47. package/src/Prebuilt/components/RoleChangeRequest/RoleChangeRequestModal.tsx +4 -1
  48. package/src/Prebuilt/components/Settings/DeviceSettings.jsx +1 -1
  49. package/src/Prebuilt/components/SidePaneTabs.tsx +3 -2
  50. package/src/Prebuilt/components/Toast/ToastConfig.jsx +1 -0
  51. package/src/Prebuilt/components/VirtualBackground/VBCollection.tsx +4 -4
  52. package/src/Prebuilt/components/VirtualBackground/{VBPicker.jsx → VBPicker.tsx} +64 -44
  53. package/src/Prebuilt/components/VirtualBackground/constants.ts +0 -8
  54. package/src/Prebuilt/components/hooks/useAutoStartStreaming.tsx +10 -1
  55. package/src/Prebuilt/components/hooks/useChatBlacklist.ts +21 -0
  56. package/src/Prebuilt/components/hooks/useSetPinnedMessages.ts +75 -0
  57. package/src/Prebuilt/components/hooks/useUserPreferences.jsx +1 -0
  58. package/src/Prebuilt/layouts/SidePane.tsx +1 -1
  59. package/src/Prebuilt/layouts/VideoStreamingSection.tsx +16 -8
  60. package/src/Prebuilt/plugins/whiteboard/PusherCommunicationProvider.js +1 -1
  61. package/src/Prebuilt/plugins/whiteboard/README.md +1 -1
  62. package/src/Prebuilt/primitives/DialogContent.jsx +1 -1
  63. package/src/Prebuilt/provider/roomLayoutProvider/constants/index.ts +12 -1
  64. package/src/Prebuilt/provider/roomLayoutProvider/hooks/useRoomLayoutScreen.ts +5 -1
  65. package/dist/chunk-WREKGNP6.js.map +0 -7
  66. package/src/Prebuilt/components/hooks/useSetPinnedMessage.js +0 -38
  67. package/src/Prebuilt/services/tokenService.js +0 -49
  68. /package/dist/{HLSView-PWVM4OIP.js.map → HLSView-IENE4HRP.js.map} +0 -0
package/package.json CHANGED
@@ -10,7 +10,7 @@
10
10
  "prebuilt",
11
11
  "roomkit"
12
12
  ],
13
- "version": "0.1.12",
13
+ "version": "0.1.13",
14
14
  "author": "100ms",
15
15
  "license": "MIT",
16
16
  "files": [
@@ -76,11 +76,11 @@
76
76
  "react": ">=17.0.2 <19.0.0"
77
77
  },
78
78
  "dependencies": {
79
- "@100mslive/hls-player": "0.1.21",
80
- "@100mslive/hms-virtual-background": "1.11.21",
81
- "@100mslive/react-icons": "0.8.21",
82
- "@100mslive/react-sdk": "0.8.21",
83
- "@100mslive/types-prebuilt": "0.12.0",
79
+ "@100mslive/hls-player": "0.1.22",
80
+ "@100mslive/hms-virtual-background": "1.11.22",
81
+ "@100mslive/react-icons": "0.8.22",
82
+ "@100mslive/react-sdk": "0.8.22",
83
+ "@100mslive/types-prebuilt": "0.12.4",
84
84
  "@emoji-mart/data": "^1.0.6",
85
85
  "@emoji-mart/react": "^1.0.1",
86
86
  "@radix-ui/react-accordion": "1.0.0",
@@ -106,6 +106,7 @@
106
106
  "qrcode.react": "^3.1.0",
107
107
  "react-draggable": "^4.4.5",
108
108
  "react-intersection-observer": "^9.4.3",
109
+ "react-swipeable": "^7.0.1",
109
110
  "react-use": "^17.4.0",
110
111
  "react-virtualized-auto-sizer": "^1.0.7",
111
112
  "react-window": "^1.8.7",
@@ -114,5 +115,5 @@
114
115
  "uuid": "^8.3.2",
115
116
  "worker-timers": "^7.0.40"
116
117
  },
117
- "gitHead": "b2409381228fa1a60f446f7873086440578f704f"
118
+ "gitHead": "543b9152024ee7e4554701f1387b1af32906b58a"
118
119
  }
@@ -9,7 +9,6 @@ import {
9
9
  useHMSActions,
10
10
  useHMSStore,
11
11
  } from '@100mslive/react-sdk';
12
- // @ts-ignore: No implicit Any
13
12
  import { AppData } from './components/AppData/AppData';
14
13
  // @ts-ignore: No implicit Any
15
14
  import AuthToken from './components/AuthToken';
@@ -62,8 +61,6 @@ export type HMSPrebuiltProps = {
62
61
  options?: HMSPrebuiltOptions;
63
62
  screens?: Screens;
64
63
  authToken?: string;
65
- roomId?: string;
66
- role?: string;
67
64
  onLeave?: () => void;
68
65
  onJoin?: () => void;
69
66
  /**
@@ -85,8 +82,6 @@ export const HMSPrebuilt = React.forwardRef<HMSPrebuiltRefType, HMSPrebuiltProps
85
82
  {
86
83
  roomCode = '',
87
84
  authToken = '',
88
- roomId = '',
89
- role = '',
90
85
  containerSelector = DEFAULT_PORTAL_CONTAINER,
91
86
  logo,
92
87
  typography,
@@ -98,7 +93,6 @@ export const HMSPrebuilt = React.forwardRef<HMSPrebuiltRefType, HMSPrebuiltProps
98
93
  },
99
94
  ref,
100
95
  ) => {
101
- const metadata = '';
102
96
  const reactiveStore = useRef<HMSPrebuiltRefType>();
103
97
 
104
98
  const [hydrated, setHydrated] = React.useState(false);
@@ -138,14 +132,12 @@ export const HMSPrebuilt = React.forwardRef<HMSPrebuiltRefType, HMSPrebuiltProps
138
132
  | {
139
133
  init: string;
140
134
  tokenByRoomCode: string;
141
- tokenByRoomIdRole: string;
142
135
  roomLayout: string;
143
136
  }
144
137
  | undefined;
145
138
  const tokenByRoomCodeEndpoint: string = endpointsObj?.tokenByRoomCode || '';
146
139
  const initEndpoint: string = endpointsObj?.init || '';
147
140
  const roomLayoutEndpoint: string = endpointsObj?.roomLayout || '';
148
- const tokenByRoomIdRoleEndpoint: string = endpointsObj?.tokenByRoomIdRole || '';
149
141
 
150
142
  const overrideLayout: Partial<Layout> = {
151
143
  logo,
@@ -154,10 +146,10 @@ export const HMSPrebuilt = React.forwardRef<HMSPrebuiltRefType, HMSPrebuiltProps
154
146
  screens,
155
147
  };
156
148
 
157
- if (!roomCode && !(authToken && roomId && role)) {
149
+ if (!roomCode && !authToken) {
158
150
  console.error(`
159
151
  HMSPrebuilt can be initialised by providing:
160
- either just "roomCode" or "authToken" and "roomId" and "role".
152
+ either "roomCode" or "authToken".
161
153
  Please check if you are providing the above values for initialising prebuilt.
162
154
  `);
163
155
  throw Error('Incorrect initializing params for HMSPrebuilt component');
@@ -174,8 +166,6 @@ export const HMSPrebuilt = React.forwardRef<HMSPrebuiltRefType, HMSPrebuiltProps
174
166
  <HMSPrebuiltContext.Provider
175
167
  value={{
176
168
  roomCode,
177
- roomId,
178
- role,
179
169
  containerSelector,
180
170
  onLeave,
181
171
  onJoin,
@@ -184,7 +174,6 @@ export const HMSPrebuilt = React.forwardRef<HMSPrebuiltRefType, HMSPrebuiltProps
184
174
  endpoints: {
185
175
  tokenByRoomCode: tokenByRoomCodeEndpoint,
186
176
  init: initEndpoint,
187
- tokenByRoomIdRole: tokenByRoomIdRoleEndpoint,
188
177
  roomLayout: roomLayoutEndpoint,
189
178
  },
190
179
  }}
@@ -222,7 +211,7 @@ export const HMSPrebuilt = React.forwardRef<HMSPrebuiltRefType, HMSPrebuiltProps
222
211
  },
223
212
  }}
224
213
  >
225
- <AppData appDetails={metadata} tokenEndpoint={tokenByRoomIdRoleEndpoint} />
214
+ <AppData />
226
215
  <Init />
227
216
  <DialogContainerProvider dialogContainerSelector={containerSelector}>
228
217
  <Box
@@ -4,8 +4,6 @@ import { DEFAULT_PORTAL_CONTAINER } from './common/constants';
4
4
 
5
5
  type HMSPrebuiltContextType = {
6
6
  roomCode: string;
7
- roomId?: string;
8
- role?: string;
9
7
  userName?: string;
10
8
  userId?: string;
11
9
  containerSelector: string;
@@ -32,7 +32,6 @@ export const APP_DATA = {
32
32
  waitingViewerRole: 'waitingViewerRole',
33
33
  subscribedNotifications: 'subscribedNotifications',
34
34
  logo: 'logo',
35
- tokenEndpoint: 'tokenEndpoint',
36
35
  appLayout: 'appLayout',
37
36
  hlsStarted: 'hlsStarted',
38
37
  rtmpStarted: 'rtmpStarted',
@@ -104,30 +103,33 @@ export const isIPadOS = false;
104
103
  // navigator?.maxTouchPoints > 2 &&
105
104
  // navigator?.userAgent?.match(/Mac/);
106
105
 
107
- export const SESSION_STORE_KEY = {
108
- TRANSCRIPTION_STATE: 'transcriptionState',
109
- PINNED_MESSAGE: 'pinnedMessage',
110
- SPOTLIGHT: 'spotlight',
111
- };
112
-
113
- export const INTERACTION_TYPE = {
114
- POLL: 'Poll',
115
- QUIZ: 'Quiz',
116
- };
117
-
118
- export const QUESTION_TYPE_TITLE = {
119
- 'single-choice': 'Single Choice',
120
- 'multiple-choice': 'Multiple Choice',
106
+ export enum SESSION_STORE_KEY {
107
+ TRANSCRIPTION_STATE = 'transcriptionState',
108
+ PINNED_MESSAGES = 'pinnedMessages',
109
+ SPOTLIGHT = 'spotlight',
110
+ CHAT_PEER_BLACKLIST = 'chatPeerBlacklist',
111
+ CHAT_MESSAGE_BLACKLIST = 'chatMessageBlacklist',
112
+ CHAT_STATE = 'chatState',
113
+ }
114
+
115
+ export enum INTERACTION_TYPE {
116
+ POLL = 'Poll',
117
+ QUIZ = 'Quiz',
118
+ }
119
+
120
+ export enum QUESTION_TYPE_TITLE {
121
+ 'single-choice' = 'Single Choice',
122
+ 'multiple-choice' = 'Multiple Choice',
121
123
  // "short-answer": "Short Answer",
122
124
  // "long-answer": "Long Answer",
123
- };
125
+ }
124
126
 
125
- export const QUESTION_TYPE = {
126
- SINGLE_CHOICE: 'single-choice',
127
- MULTIPLE_CHOICE: 'multiple-choice',
127
+ export enum QUESTION_TYPE {
128
+ SINGLE_CHOICE = 'single-choice',
129
+ MULTIPLE_CHOICE = 'multiple-choice',
128
130
  // SHORT_ANSWER: "short-answer",
129
131
  // LONG_ANSWER: "long-answer",
130
- };
132
+ }
131
133
 
132
134
  export const ROLE_CHANGE_DECLINED = 'role_change_declined';
133
135
 
@@ -12,9 +12,13 @@ import {
12
12
  useHMSStore,
13
13
  useRecordingStreaming,
14
14
  } from '@100mslive/react-sdk';
15
+ //@ts-ignore
15
16
  import { normalizeAppPolicyConfig } from '../init/initUtils';
17
+ //@ts-ignore
16
18
  import { UserPreferencesKeys, useUserPreferences } from '../hooks/useUserPreferences';
19
+ // @ts-ignore
17
20
  import { useIsSidepaneTypeOpen, useSidepaneToggle } from './useSidepane';
21
+ // @ts-ignore
18
22
  import { useSetAppDataByKey } from './useUISettings';
19
23
  import {
20
24
  APP_DATA,
@@ -25,15 +29,6 @@ import {
25
29
  UI_MODE_GRID,
26
30
  UI_SETTINGS,
27
31
  } from '../../common/constants';
28
- import { VB_EFFECT } from '../VirtualBackground/constants';
29
-
30
- export const getAppDetails = appDetails => {
31
- try {
32
- return !appDetails ? {} : JSON.parse(appDetails);
33
- } catch (error) {
34
- return {};
35
- }
36
- };
37
32
 
38
33
  const initialAppData = {
39
34
  [APP_DATA.uiSettings]: {
@@ -67,15 +62,15 @@ const initialAppData = {
67
62
  [APP_DATA.minimiseInset]: false,
68
63
  [APP_DATA.activeScreensharePeerId]: '',
69
64
  [APP_DATA.disableNotifications]: false,
70
- [APP_DATA.background]: VB_EFFECT.NONE,
71
- [APP_DATA.backgroundType]: VB_EFFECT.NONE,
65
+ [APP_DATA.background]: 'none',
66
+ [APP_DATA.backgroundType]: 'none',
72
67
  [APP_DATA.pollState]: {
73
68
  [POLL_STATE.pollInView]: '',
74
69
  [POLL_STATE.view]: '',
75
70
  },
76
71
  };
77
72
 
78
- export const AppData = React.memo(({ appDetails, tokenEndpoint }) => {
73
+ export const AppData = React.memo(() => {
79
74
  const hmsActions = useHMSActions();
80
75
  const [preferences = {}] = useUserPreferences(UserPreferencesKeys.UI_SETTINGS);
81
76
  const roleNames = useHMSStore(selectAvailableRoleNames);
@@ -88,6 +83,7 @@ export const AppData = React.memo(({ appDetails, tokenEndpoint }) => {
88
83
  ...initialAppData,
89
84
  ...appData,
90
85
  });
86
+ // @ts-ignore
91
87
  hmsActions.setFrameworkInfo({
92
88
  type: 'react-web',
93
89
  isPrebuilt: true,
@@ -105,16 +101,6 @@ export const AppData = React.memo(({ appDetails, tokenEndpoint }) => {
105
101
  hmsActions.setAppData(APP_DATA.uiSettings, updatedSettings, true);
106
102
  }, [preferences, hmsActions]);
107
103
 
108
- useEffect(() => {
109
- const appData = {
110
- [APP_DATA.tokenEndpoint]: tokenEndpoint,
111
- [APP_DATA.appConfig]: getAppDetails(appDetails),
112
- };
113
- for (const key in appData) {
114
- hmsActions.setAppData([key], appData[key]);
115
- }
116
- }, [appDetails, tokenEndpoint, hmsActions]);
117
-
118
104
  useEffect(() => {
119
105
  if (!preferences.subscribedNotifications) {
120
106
  return;
@@ -59,10 +59,6 @@ export const useIsRTMPStartedFromUI = () => {
59
59
  return useHMSStore(selectAppData(APP_DATA.rtmpStarted));
60
60
  };
61
61
 
62
- export const useTokenEndpoint = () => {
63
- return useHMSStore(selectAppData(APP_DATA.tokenEndpoint));
64
- };
65
-
66
62
  export const useAuthToken = () => {
67
63
  return useHMSStore(selectAppData(APP_DATA.authToken));
68
64
  };
@@ -1,9 +1,12 @@
1
1
  import React, { useEffect, useState } from 'react';
2
+ import { useSessionStorage } from 'react-use';
3
+ import { v4 } from 'uuid';
2
4
  import { useHMSActions } from '@100mslive/react-sdk';
3
5
  import { styled } from '../../Theme';
4
6
  import { useHMSPrebuiltContext } from '../AppContext';
5
7
  import { ErrorDialog } from '../primitives/DialogContent';
6
- import { useSetAppDataByKey, useTokenEndpoint } from './AppData/useUISettings';
8
+ import { useSetAppDataByKey } from './AppData/useUISettings';
9
+ import { UserPreferencesKeys } from './hooks/useUserPreferences';
7
10
  import { APP_DATA } from '../common/constants';
8
11
 
9
12
  /**
@@ -17,26 +20,33 @@ import { APP_DATA } from '../common/constants';
17
20
  */
18
21
  const AuthToken = React.memo(({ authTokenByRoomCodeEndpoint, defaultAuthToken }) => {
19
22
  const hmsActions = useHMSActions();
20
- const tokenEndpoint = useTokenEndpoint();
21
23
  const { roomCode, userId } = useHMSPrebuiltContext();
22
24
  const [error, setError] = useState({ title: '', body: '' });
23
25
  let authToken = defaultAuthToken;
24
26
  const [, setAuthTokenInAppData] = useSetAppDataByKey(APP_DATA.authToken);
27
+ const [savedUserId, setSavedUserId] = useSessionStorage(UserPreferencesKeys.USER_ID);
28
+
29
+ useEffect(() => {
30
+ if (!savedUserId && !userId) {
31
+ setSavedUserId(v4());
32
+ }
33
+ }, [savedUserId, setSavedUserId, userId]);
25
34
 
26
35
  useEffect(() => {
27
36
  if (authToken) {
28
37
  setAuthTokenInAppData(authToken);
29
38
  return;
30
39
  }
31
- if (!tokenEndpoint && !roomCode) {
40
+
41
+ if (!roomCode) {
32
42
  return;
33
43
  }
34
44
 
35
45
  hmsActions
36
- .getAuthTokenByRoomCode({ roomCode, userId }, { endpoint: authTokenByRoomCodeEndpoint })
46
+ .getAuthTokenByRoomCode({ roomCode, userId: userId || savedUserId }, { endpoint: authTokenByRoomCodeEndpoint })
37
47
  .then(token => setAuthTokenInAppData(token))
38
48
  .catch(error => setError(convertError(error)));
39
- }, [hmsActions, tokenEndpoint, authToken, authTokenByRoomCodeEndpoint, setAuthTokenInAppData, roomCode, userId]);
49
+ }, [hmsActions, authToken, authTokenByRoomCodeEndpoint, setAuthTokenInAppData, roomCode, userId, savedUserId]);
40
50
 
41
51
  if (error.title) {
42
52
  return <ErrorDialog title={error.title}>{error.body}</ErrorDialog>;
@@ -1,76 +1,34 @@
1
1
  import React, { useCallback, useEffect, useRef, useState } from 'react';
2
2
  import { useMedia } from 'react-use';
3
+ import { selectLocalPeer, selectSessionStore } from '@100mslive/hms-video-store';
3
4
  import {
4
5
  HMSNotificationTypes,
5
6
  selectHMSMessagesCount,
6
7
  selectPeerNameByID,
7
- selectPermissions,
8
- selectSessionStore,
9
8
  useHMSActions,
10
9
  useHMSNotifications,
11
10
  useHMSStore,
12
11
  } from '@100mslive/react-sdk';
13
- import { ChevronDownIcon, CrossIcon, PinIcon } from '@100mslive/react-icons';
12
+ import { ChevronDownIcon } from '@100mslive/react-icons';
14
13
  import { Button } from '../../../Button';
15
- import { Box, Flex } from '../../../Layout';
16
- import { Text } from '../../../Text';
14
+ import { Flex } from '../../../Layout';
17
15
  import { config as cssConfig } from '../../../Theme';
18
- import { AnnotisedMessage, ChatBody } from './ChatBody';
16
+ import { ChatBody } from './ChatBody';
19
17
  import { ChatFooter } from './ChatFooter';
18
+ import { ChatBlocked, ChatPaused } from './ChatStates';
19
+ import { PinnedMessage } from './PinnedMessage';
20
20
  import { useRoomLayoutConferencingScreen } from '../../provider/roomLayoutProvider/hooks/useRoomLayoutScreen';
21
21
  import { useSetSubscribedChatSelector } from '../AppData/useUISettings';
22
- import { useSetPinnedMessage } from '../hooks/useSetPinnedMessage';
22
+ import { useSetPinnedMessages } from '../hooks/useSetPinnedMessages';
23
23
  import { useUnreadCount } from './useUnreadCount';
24
24
  import { CHAT_SELECTOR, SESSION_STORE_KEY } from '../../common/constants';
25
25
 
26
- const PINNED_MESSAGE_LENGTH = 80;
27
-
28
- const PinnedMessage = ({ clearPinnedMessage }) => {
29
- const permissions = useHMSStore(selectPermissions);
30
- const pinnedMessage = useHMSStore(selectSessionStore(SESSION_STORE_KEY.PINNED_MESSAGE));
31
- const formattedPinnedMessage =
32
- pinnedMessage?.length && pinnedMessage.length > PINNED_MESSAGE_LENGTH
33
- ? `${pinnedMessage.slice(0, PINNED_MESSAGE_LENGTH)}...`
34
- : pinnedMessage;
35
-
36
- return pinnedMessage ? (
37
- <Flex
38
- title={pinnedMessage}
39
- css={{ p: '$4', color: '$on_surface_medium', bg: '$surface_default', r: '$1', gap: '$4', mb: '$8', mt: '$8' }}
40
- align="center"
41
- justify="between"
42
- >
43
- <PinIcon />
44
-
45
- <Box
46
- css={{
47
- color: '$on_surface_medium',
48
- w: '100%',
49
- maxHeight: '$18',
50
- overflowY: 'auto',
51
- }}
52
- >
53
- <Text variant="sm">
54
- <AnnotisedMessage message={formattedPinnedMessage} />
55
- </Text>
56
- </Box>
57
- {permissions.removeOthers && (
58
- <Flex
59
- onClick={() => clearPinnedMessage()}
60
- css={{ cursor: 'pointer', color: '$on_surface_medium', '&:hover': { color: '$on_surface_high' } }}
61
- >
62
- <CrossIcon />
63
- </Flex>
64
- )}
65
- </Flex>
66
- ) : null;
67
- };
68
-
69
26
  export const Chat = ({ screenType }) => {
70
27
  const notification = useHMSNotifications(HMSNotificationTypes.PEER_LEFT);
71
28
  const [peerSelector, setPeerSelector] = useSetSubscribedChatSelector(CHAT_SELECTOR.PEER_ID);
72
29
  const [roleSelector, setRoleSelector] = useSetSubscribedChatSelector(CHAT_SELECTOR.ROLE);
73
30
  const peerName = useHMSStore(selectPeerNameByID(peerSelector));
31
+ const localPeer = useHMSStore(selectLocalPeer);
74
32
  const [chatOptions, setChatOptions] = useState({
75
33
  role: roleSelector || '',
76
34
  peerId: peerSelector && peerName ? peerSelector : '',
@@ -79,7 +37,8 @@ export const Chat = ({ screenType }) => {
79
37
  const [isSelectorOpen] = useState(false);
80
38
  const listRef = useRef(null);
81
39
  const hmsActions = useHMSActions();
82
- const { setPinnedMessage } = useSetPinnedMessage();
40
+ const { removePinnedMessage } = useSetPinnedMessages();
41
+ const pinnedMessages = useHMSStore(selectSessionStore(SESSION_STORE_KEY.PINNED_MESSAGES)) || [];
83
42
 
84
43
  useEffect(() => {
85
44
  if (notification && notification.data && peerSelector === notification.data.id) {
@@ -91,9 +50,12 @@ export const Chat = ({ screenType }) => {
91
50
  });
92
51
  }
93
52
  }, [notification, peerSelector, setPeerSelector]);
94
-
53
+ const blacklistedPeerIDs = useHMSStore(selectSessionStore(SESSION_STORE_KEY.CHAT_PEER_BLACKLIST)) || [];
54
+ const blacklistedPeerIDSet = new Set(blacklistedPeerIDs);
55
+ const isLocalPeerBlacklisted = blacklistedPeerIDSet.has(localPeer?.customerUserId);
95
56
  const storeMessageSelector = selectHMSMessagesCount;
96
57
  const { elements } = useRoomLayoutConferencingScreen();
58
+ const { enabled: isChatEnabled = true } = useHMSStore(selectSessionStore(SESSION_STORE_KEY.CHAT_STATE)) || {};
97
59
  const isMobile = useMedia(cssConfig.media.md);
98
60
 
99
61
  let isScrolledToBottom = false;
@@ -125,7 +87,9 @@ export const Chat = ({ screenType }) => {
125
87
  }}
126
88
  >
127
89
  {isMobile && elements?.chat?.is_overlay ? null : (
128
- <>{elements?.chat?.allow_pinning_messages ? <PinnedMessage clearPinnedMessage={setPinnedMessage} /> : null}</>
90
+ <>
91
+ <PinnedMessage clearPinnedMessage={index => removePinnedMessage(pinnedMessages, index)} />
92
+ </>
129
93
  )}
130
94
 
131
95
  <ChatBody
@@ -134,27 +98,39 @@ export const Chat = ({ screenType }) => {
134
98
  ref={listRef}
135
99
  scrollToBottom={scrollToBottom}
136
100
  screenType={screenType}
101
+ blacklistedPeerIDs={blacklistedPeerIDs}
137
102
  />
138
- <ChatFooter
139
- role={chatOptions.role}
140
- onSend={() => scrollToBottom(1)}
141
- selection={chatOptions.selection}
142
- screenType={screenType}
143
- onSelect={({ role, peerId, selection }) => {
144
- setChatOptions({
145
- role,
146
- peerId,
147
- selection,
148
- });
149
- setPeerSelector(peerId);
150
- setRoleSelector(role);
151
- }}
152
- peerId={chatOptions.peerId}
153
- >
154
- {!isSelectorOpen && !isScrolledToBottom && (
155
- <NewMessageIndicator role={chatOptions.role} peerId={chatOptions.peerId} scrollToBottom={scrollToBottom} />
156
- )}
157
- </ChatFooter>
103
+
104
+ <ChatPaused />
105
+
106
+ {isLocalPeerBlacklisted ? <ChatBlocked /> : null}
107
+
108
+ {isMobile && elements?.chat?.is_overlay ? (
109
+ <PinnedMessage clearPinnedMessage={index => removePinnedMessage(pinnedMessages, index)} />
110
+ ) : null}
111
+
112
+ {isChatEnabled && !isLocalPeerBlacklisted ? (
113
+ <ChatFooter
114
+ role={chatOptions.role}
115
+ onSend={() => scrollToBottom(1)}
116
+ selection={chatOptions.selection}
117
+ screenType={screenType}
118
+ onSelect={({ role, peerId, selection }) => {
119
+ setChatOptions({
120
+ role,
121
+ peerId,
122
+ selection,
123
+ });
124
+ setPeerSelector(peerId);
125
+ setRoleSelector(role);
126
+ }}
127
+ peerId={chatOptions.peerId}
128
+ >
129
+ {!isSelectorOpen && !isScrolledToBottom && (
130
+ <NewMessageIndicator role={chatOptions.role} peerId={chatOptions.peerId} scrollToBottom={scrollToBottom} />
131
+ )}
132
+ </ChatFooter>
133
+ ) : null}
158
134
  </Flex>
159
135
  );
160
136
  };