@100mslive/roomkit-react 0.1.18-alpha.0 → 0.1.18

Sign up to get free protection for your applications and to get access to all the features.
Files changed (38) hide show
  1. package/dist/{HLSView-GYHK4ION.js → HLSView-XU2WQ4VV.js} +2 -2
  2. package/dist/Prebuilt/components/Chat/Chat.d.ts +2 -0
  3. package/dist/Prebuilt/components/Chat/ChatActions.d.ts +12 -0
  4. package/dist/Prebuilt/components/Chat/ChatBody.d.ts +8 -0
  5. package/dist/Prebuilt/components/Chat/ChatFooter.d.ts +2 -2
  6. package/dist/Prebuilt/components/Chat/ChatStates.d.ts +1 -1
  7. package/dist/Prebuilt/components/Chat/MwebChatOption.d.ts +1 -1
  8. package/dist/Prebuilt/components/Chat/PinnedMessage.d.ts +1 -3
  9. package/dist/Prebuilt/components/hooks/useChatBlacklist.d.ts +1 -0
  10. package/dist/Prebuilt/components/hooks/useSetPinnedMessages.d.ts +3 -10
  11. package/dist/Prebuilt/components/hooks/useUnreadPollQuizPresent.d.ts +5 -0
  12. package/dist/{chunk-75O2M72S.js → chunk-2FX6MFDM.js} +4541 -4502
  13. package/dist/chunk-2FX6MFDM.js.map +7 -0
  14. package/dist/index.cjs.js +5113 -5059
  15. package/dist/index.cjs.js.map +4 -4
  16. package/dist/index.js +1 -1
  17. package/dist/meta.cjs.json +343 -225
  18. package/dist/meta.esbuild.json +353 -235
  19. package/package.json +6 -6
  20. package/src/Prebuilt/components/Chat/Chat.tsx +108 -0
  21. package/src/Prebuilt/components/Chat/ChatActions.tsx +295 -0
  22. package/src/Prebuilt/components/Chat/ChatBody.tsx +444 -0
  23. package/src/Prebuilt/components/Chat/ChatFooter.tsx +9 -3
  24. package/src/Prebuilt/components/Chat/ChatStates.tsx +5 -0
  25. package/src/Prebuilt/components/Chat/MwebChatOption.tsx +1 -1
  26. package/src/Prebuilt/components/Chat/PinnedMessage.tsx +4 -2
  27. package/src/Prebuilt/components/Footer/PollsToggle.tsx +12 -3
  28. package/src/Prebuilt/components/Leave/DesktopLeaveRoom.tsx +4 -3
  29. package/src/Prebuilt/components/MoreSettings/SplitComponents/MwebOptions.tsx +5 -1
  30. package/src/Prebuilt/components/Polls/common/MultipleChoiceOptions.jsx +1 -1
  31. package/src/Prebuilt/components/SidePaneTabs.tsx +33 -11
  32. package/src/Prebuilt/components/hooks/useChatBlacklist.ts +7 -1
  33. package/src/Prebuilt/components/hooks/useSetPinnedMessages.ts +19 -11
  34. package/src/Prebuilt/components/hooks/useUnreadPollQuizPresent.tsx +20 -0
  35. package/dist/chunk-75O2M72S.js.map +0 -7
  36. package/src/Prebuilt/components/Chat/Chat.jsx +0 -124
  37. package/src/Prebuilt/components/Chat/ChatBody.jsx +0 -726
  38. /package/dist/{HLSView-GYHK4ION.js.map → HLSView-XU2WQ4VV.js.map} +0 -0
@@ -107,16 +107,37 @@ export const SidePaneTabs = React.memo<{
107
107
  <>
108
108
  {hideTabs ? (
109
109
  <>
110
- <Text variant="sm" css={{ fontWeight: '$semiBold', p: '$4', c: '$on_surface_high', pr: '$12' }}>
111
- {showChat ? (
112
- chat_title
113
- ) : (
114
- <span>
115
- Participants <ParticipantCount count={peerCount} />
116
- </span>
117
- )}
118
- </Text>
119
-
110
+ <Flex justify="between" css={{ w: '100%' }}>
111
+ <Text variant="sm" css={{ fontWeight: '$semiBold', p: '$4', c: '$on_surface_high', pr: '$12' }}>
112
+ {showChat ? (
113
+ chat_title
114
+ ) : (
115
+ <span>
116
+ Participants&nbsp;
117
+ <ParticipantCount count={peerCount} />
118
+ </span>
119
+ )}
120
+ </Text>
121
+ <Flex>
122
+ {showChatSettings ? <ChatSettings /> : null}
123
+ {isOverlayChat && isChatOpen ? null : (
124
+ <IconButton
125
+ css={{ my: '$1', color: '$on_surface_medium', '&:hover': { color: '$on_surface_high' } }}
126
+ onClick={e => {
127
+ e.stopPropagation();
128
+ if (activeTab === SIDE_PANE_OPTIONS.CHAT) {
129
+ toggleChat();
130
+ } else {
131
+ toggleParticipants();
132
+ }
133
+ }}
134
+ data-testid="close_chat"
135
+ >
136
+ <CrossIcon />
137
+ </IconButton>
138
+ )}
139
+ </Flex>
140
+ </Flex>
120
141
  {showChat ? <Chat /> : <ParticipantList offStageRoles={off_stage_roles} onActive={setActiveRole} />}
121
142
  </>
122
143
  ) : (
@@ -148,7 +169,8 @@ export const SidePaneTabs = React.memo<{
148
169
  color: activeTab !== SIDE_PANE_OPTIONS.PARTICIPANTS ? '$on_surface_low' : '$on_surface_high',
149
170
  }}
150
171
  >
151
- Participants &nbsp; <ParticipantCount count={peerCount} />
172
+ Participants&nbsp;
173
+ <ParticipantCount count={peerCount} />
152
174
  </Tabs.Trigger>
153
175
  </Tabs.List>
154
176
  {showChatSettings ? <ChatSettings /> : null}
@@ -1,5 +1,5 @@
1
1
  import { useCallback } from 'react';
2
- import { selectSessionStore, useHMSActions, useHMSStore } from '@100mslive/react-sdk';
2
+ import { selectLocalPeer, selectSessionStore, useHMSActions, useHMSStore } from '@100mslive/react-sdk';
3
3
  // @ts-ignore
4
4
  import { ToastManager } from '../Toast/ToastManager';
5
5
  import { SESSION_STORE_KEY } from '../../common/constants';
@@ -21,3 +21,9 @@ export const useChatBlacklist = (
21
21
 
22
22
  return { blacklistItem, blacklistedIDs };
23
23
  };
24
+
25
+ export const useIsLocalPeerBlacklisted = () => {
26
+ const localPeer = useHMSStore(selectLocalPeer);
27
+ const blacklistedPeerIDs = useHMSStore(selectSessionStore(SESSION_STORE_KEY.CHAT_PEER_BLACKLIST)) || [];
28
+ return blacklistedPeerIDs?.includes(localPeer?.customerUserId);
29
+ };
@@ -1,5 +1,11 @@
1
1
  import { useCallback } from 'react';
2
- import { HMSMessage, selectPeerNameByID, useHMSActions, useHMSVanillaStore } from '@100mslive/react-sdk';
2
+ import {
3
+ HMSMessage,
4
+ selectPeerNameByID,
5
+ selectSessionStore,
6
+ useHMSActions,
7
+ useHMSVanillaStore,
8
+ } from '@100mslive/react-sdk';
3
9
  // @ts-ignore
4
10
  import { ToastManager } from '../Toast/ToastManager';
5
11
  // @ts-ignore
@@ -8,7 +14,6 @@ import { SESSION_STORE_KEY } from '../../common/constants';
8
14
  type PinnedMessage = {
9
15
  text: string;
10
16
  id: string;
11
- authorId: string;
12
17
  pinnedBy: string;
13
18
  };
14
19
 
@@ -20,9 +25,9 @@ export const useSetPinnedMessages = () => {
20
25
  const vanillaStore = useHMSVanillaStore();
21
26
 
22
27
  const setPinnedMessages = useCallback(
23
- async (pinnedMessages: PinnedMessage[] = [], message: HMSMessage, pinnedBy: string) => {
28
+ async (message: HMSMessage, pinnedBy: string) => {
24
29
  const peerName = vanillaStore.getState(selectPeerNameByID(message?.sender)) || message?.senderName;
25
- const newPinnedMessage = { text: '', id: message.id, pinnedBy, authorId: message?.senderUserId || '' };
30
+ const newPinnedMessage = { text: '', id: message.id, pinnedBy };
26
31
 
27
32
  if (message && peerName) {
28
33
  newPinnedMessage['text'] = `${peerName}: ${message.message}`;
@@ -30,7 +35,8 @@ export const useSetPinnedMessages = () => {
30
35
  newPinnedMessage['text'] = message.message;
31
36
  }
32
37
 
33
- if (newPinnedMessage && !pinnedMessages.find(pinnedMessage => pinnedMessage.id === newPinnedMessage.id)) {
38
+ const pinnedMessages = vanillaStore.getState(selectSessionStore(SESSION_STORE_KEY.PINNED_MESSAGES)) || [];
39
+ if (!pinnedMessages?.find((pinnedMessage: PinnedMessage) => pinnedMessage.id === newPinnedMessage.id)) {
34
40
  await hmsActions.sessionStore
35
41
  .set(SESSION_STORE_KEY.PINNED_MESSAGES, [...pinnedMessages, newPinnedMessage].slice(-3)) // Limiting to maximum of 3 messages - FIFO
36
42
  .catch(err => ToastManager.addToast({ title: err.description }));
@@ -40,30 +46,32 @@ export const useSetPinnedMessages = () => {
40
46
  );
41
47
 
42
48
  const removePinnedMessage = useCallback(
43
- async (pinnedMessages: PinnedMessage[] = [], indexToRemove: number) => {
49
+ async (indexToRemove: number) => {
50
+ const pinnedMessages = vanillaStore.getState(selectSessionStore(SESSION_STORE_KEY.PINNED_MESSAGES)) || [];
44
51
  if (pinnedMessages[indexToRemove]) {
45
52
  await hmsActions.sessionStore
46
53
  .set(
47
54
  SESSION_STORE_KEY.PINNED_MESSAGES,
48
- pinnedMessages.filter((_, index: number) => index !== indexToRemove),
55
+ pinnedMessages.filter((_: PinnedMessage, index: number) => index !== indexToRemove),
49
56
  )
50
57
  .catch(err => ToastManager.addToast({ title: err.description }));
51
58
  }
52
59
  },
53
- [hmsActions],
60
+ [hmsActions, vanillaStore],
54
61
  );
55
62
 
56
63
  const unpinBlacklistedMessages = useCallback(
57
- async (pinnedMessages: PinnedMessage[] = [], blacklistedMessageIDSet: Set<string>) => {
64
+ async (blacklistedMessageIDSet: Set<string>) => {
65
+ const pinnedMessages = vanillaStore.getState(selectSessionStore(SESSION_STORE_KEY.PINNED_MESSAGES)) || [];
58
66
  const filteredPinnedMessages = pinnedMessages?.filter(
59
- pinnedMessage => !blacklistedMessageIDSet?.has(pinnedMessage.id),
67
+ (pinnedMessage: PinnedMessage) => !blacklistedMessageIDSet?.has(pinnedMessage.id),
60
68
  );
61
69
 
62
70
  await hmsActions.sessionStore
63
71
  .set(SESSION_STORE_KEY.PINNED_MESSAGES, filteredPinnedMessages)
64
72
  .catch(err => ToastManager.addToast({ title: err.description }));
65
73
  },
66
- [hmsActions],
74
+ [hmsActions, vanillaStore],
67
75
  );
68
76
 
69
77
  return { setPinnedMessages, removePinnedMessage, unpinBlacklistedMessages };
@@ -0,0 +1,20 @@
1
+ import { useEffect, useState } from 'react';
2
+ import { selectLocalPeerID } from '@100mslive/hms-video-store';
3
+ import { HMSNotificationTypes, useHMSNotifications, useHMSStore } from '@100mslive/react-sdk';
4
+
5
+ export const useUnreadPollQuizPresent = () => {
6
+ const localPeerID = useHMSStore(selectLocalPeerID);
7
+ const notification = useHMSNotifications();
8
+ const [unreadPollQuiz, setUnreadPollQuiz] = useState(false);
9
+
10
+ useEffect(() => {
11
+ if (!notification) {
12
+ return;
13
+ }
14
+ if (notification.type !== HMSNotificationTypes.POLL_STARTED) {
15
+ return;
16
+ }
17
+ setUnreadPollQuiz(notification.data.startedBy !== localPeerID);
18
+ }, [localPeerID, notification]);
19
+ return { unreadPollQuiz, setUnreadPollQuiz };
20
+ };