@100mslive/roomkit-react 0.1.18-alpha.1 → 0.1.18
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/{HLSView-MR7RYQZB.js → HLSView-XU2WQ4VV.js} +2 -2
- package/dist/Prebuilt/components/Chat/Chat.d.ts +2 -0
- package/dist/Prebuilt/components/Chat/ChatActions.d.ts +12 -0
- package/dist/Prebuilt/components/Chat/ChatBody.d.ts +8 -0
- package/dist/Prebuilt/components/Chat/ChatFooter.d.ts +2 -2
- package/dist/Prebuilt/components/Chat/ChatStates.d.ts +1 -1
- package/dist/Prebuilt/components/Chat/MwebChatOption.d.ts +1 -1
- package/dist/Prebuilt/components/Chat/PinnedMessage.d.ts +1 -3
- package/dist/Prebuilt/components/hooks/useChatBlacklist.d.ts +1 -0
- package/dist/Prebuilt/components/hooks/useSetPinnedMessages.d.ts +3 -10
- package/dist/Prebuilt/components/hooks/useUnreadPollQuizPresent.d.ts +5 -0
- package/dist/{chunk-WFHOR7AP.js → chunk-2FX6MFDM.js} +4535 -4495
- package/dist/chunk-2FX6MFDM.js.map +7 -0
- package/dist/index.cjs.js +5110 -5055
- package/dist/index.cjs.js.map +4 -4
- package/dist/index.js +1 -1
- package/dist/meta.cjs.json +341 -223
- package/dist/meta.esbuild.json +351 -233
- package/package.json +6 -6
- package/src/Prebuilt/components/Chat/Chat.tsx +108 -0
- package/src/Prebuilt/components/Chat/ChatActions.tsx +295 -0
- package/src/Prebuilt/components/Chat/ChatBody.tsx +444 -0
- package/src/Prebuilt/components/Chat/ChatFooter.tsx +9 -3
- package/src/Prebuilt/components/Chat/ChatStates.tsx +5 -0
- package/src/Prebuilt/components/Chat/MwebChatOption.tsx +1 -1
- package/src/Prebuilt/components/Chat/PinnedMessage.tsx +4 -2
- package/src/Prebuilt/components/Footer/PollsToggle.tsx +12 -3
- package/src/Prebuilt/components/MoreSettings/SplitComponents/MwebOptions.tsx +5 -1
- package/src/Prebuilt/components/Polls/common/MultipleChoiceOptions.jsx +1 -1
- package/src/Prebuilt/components/SidePaneTabs.tsx +33 -11
- package/src/Prebuilt/components/hooks/useChatBlacklist.ts +7 -1
- package/src/Prebuilt/components/hooks/useSetPinnedMessages.ts +19 -11
- package/src/Prebuilt/components/hooks/useUnreadPollQuizPresent.tsx +20 -0
- package/dist/chunk-WFHOR7AP.js.map +0 -7
- package/src/Prebuilt/components/Chat/Chat.jsx +0 -124
- package/src/Prebuilt/components/Chat/ChatBody.jsx +0 -726
- /package/dist/{HLSView-MR7RYQZB.js.map → HLSView-XU2WQ4VV.js.map} +0 -0
@@ -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 {
|
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 (
|
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
|
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
|
-
|
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 (
|
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 (
|
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
|
+
};
|