@ethora/chat-component-rn 26.4.1
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.
- package/LICENSE +661 -0
- package/README.md +148 -0
- package/empty-shim.js +15 -0
- package/index.js +13 -0
- package/metro.js +72 -0
- package/package.json +99 -0
- package/src/api.config.ts +34 -0
- package/src/assets/BG.png +0 -0
- package/src/assets/BG.tsx +56 -0
- package/src/assets/File.svg +4 -0
- package/src/assets/ForzaCare.png +0 -0
- package/src/assets/ForzaCare.tsx +27 -0
- package/src/assets/icons.tsx +685 -0
- package/src/assets/images.tsx +41 -0
- package/src/assets/test.xml +243 -0
- package/src/components/AuthForms/Login.tsx +295 -0
- package/src/components/AuthForms/LoginAnonym.tsx +68 -0
- package/src/components/AuthForms/Register.tsx +8 -0
- package/src/components/ContextMenu/ContextMenuComponents.tsx +87 -0
- package/src/components/DropdownMenu/DropdownMenu.tsx +244 -0
- package/src/components/ExampleComponents/CustomMessage.tsx +92 -0
- package/src/components/ExampleComponents/CustomTypingIndicatorExamples.tsx +239 -0
- package/src/components/Header/HeaderRoomList.tsx +104 -0
- package/src/components/InputComponents/AudioInput.tsx +24 -0
- package/src/components/InputComponents/AudioRecorder.tsx +100 -0
- package/src/components/InputComponents/MediaInput.tsx +114 -0
- package/src/components/InputComponents/RecordingIndicator.tsx +77 -0
- package/src/components/InputComponents/Search.tsx +135 -0
- package/src/components/InputComponents/TextInput.tsx +66 -0
- package/src/components/MainComponents/ChatHeader.tsx +163 -0
- package/src/components/MainComponents/ChatRoom.tsx +392 -0
- package/src/components/MainComponents/ChatWrapper.tsx +318 -0
- package/src/components/MainComponents/ChooseChatMessage.tsx +44 -0
- package/src/components/MainComponents/ConnectionBanner.tsx +33 -0
- package/src/components/MainComponents/EditWrapper.tsx +72 -0
- package/src/components/MainComponents/LoginWrapper.tsx +134 -0
- package/src/components/MainComponents/MediaMessage.tsx +55 -0
- package/src/components/MainComponents/MessageContainer.tsx +122 -0
- package/src/components/MainComponents/MessageList.tsx +429 -0
- package/src/components/MainComponents/NoMessagesPlaceholder.tsx +49 -0
- package/src/components/MainComponents/ProfileImagePlaceholder.tsx +143 -0
- package/src/components/MainComponents/RNStyled.tsx +34 -0
- package/src/components/MainComponents/ReduxWrapper.tsx +40 -0
- package/src/components/MainComponents/RoomList.tsx +246 -0
- package/src/components/MainComponents/Select.tsx +165 -0
- package/src/components/MainComponents/Switch.tsx +73 -0
- package/src/components/MainComponents/SystemMessage.tsx +42 -0
- package/src/components/Menu/HeaderRoomListMenu.tsx +169 -0
- package/src/components/MenuRoom/MenuRoom.tsx +46 -0
- package/src/components/MessageBubble/Avatar.tsx +84 -0
- package/src/components/MessageBubble/BottomReplyContainer.tsx +117 -0
- package/src/components/MessageBubble/CustomDivider.tsx +10 -0
- package/src/components/MessageBubble/DeletedMessage.tsx +36 -0
- package/src/components/MessageBubble/Message.tsx +400 -0
- package/src/components/MessageBubble/MessageInteractions.tsx +247 -0
- package/src/components/MessageBubble/MessageReaction.tsx +149 -0
- package/src/components/MessageBubble/MessageReply.tsx +50 -0
- package/src/components/MessageBubble/MessageTranslations.tsx +30 -0
- package/src/components/Modals/AddMembersModal/AddMembersModal.tsx +142 -0
- package/src/components/Modals/ChatProfileModal/ChatProfileModal.tsx +471 -0
- package/src/components/Modals/ChatProfileModal/DeleteChatModal.tsx +91 -0
- package/src/components/Modals/FilePreviewModal/FilePreviewModal.tsx +298 -0
- package/src/components/Modals/Modal/Modal.tsx +52 -0
- package/src/components/Modals/ModalHeaderComponent.tsx +41 -0
- package/src/components/Modals/ModalSelectMedia/ModalSelectMedia.tsx +285 -0
- package/src/components/Modals/ModalWrapper/ModalWrapper.tsx +103 -0
- package/src/components/Modals/NewChatModal/ModalContent.tsx +151 -0
- package/src/components/Modals/NewChatModal/NewChatModal.tsx +391 -0
- package/src/components/Modals/NewChatModal/UpdNewChatModal.tsx +136 -0
- package/src/components/Modals/SelectUsersModal/SelectUsersModal.tsx +134 -0
- package/src/components/Modals/SettingsModals/BlockedUsers/BlockedUsersModal.tsx +63 -0
- package/src/components/Modals/SettingsModals/DocumentShares/DocumentSharesModal.tsx +115 -0
- package/src/components/Modals/SettingsModals/ManageDataModal/ManageDataModal.tsx +121 -0
- package/src/components/Modals/SettingsModals/ManageDataModal/StyledComponents.ts +0 -0
- package/src/components/Modals/SettingsModals/ProfileShares/ProfileShares.tsx +65 -0
- package/src/components/Modals/SettingsModals/Referrals/Referrals.tsx +90 -0
- package/src/components/Modals/SettingsModals/SharedStyledComponents.ts +74 -0
- package/src/components/Modals/SettingsModals/Visibility/RadioInput.tsx +59 -0
- package/src/components/Modals/SettingsModals/Visibility/StyledComponents.ts +32 -0
- package/src/components/Modals/SettingsModals/Visibility/VisibilityModal.tsx +146 -0
- package/src/components/Modals/UserProfileModal/EditUserModal.tsx +163 -0
- package/src/components/Modals/UserProfileModal/UserProfileModal.tsx +410 -0
- package/src/components/Modals/UserSettingsModal/UserSettingsModal.tsx +85 -0
- package/src/components/Modals/styledModalComponents.tsx +181 -0
- package/src/components/OperationalModal/OperationalModal.tsx +78 -0
- package/src/components/RoomComponents/ChatRoomItem.tsx +219 -0
- package/src/components/RoomComponents/LastMessageItem.tsx +47 -0
- package/src/components/RoomComponents/styled/LastAudioMessage.tsx +62 -0
- package/src/components/RoomComponents/styled/LastMessageEmoji.tsx +26 -0
- package/src/components/RoomComponents/styled/LastMessageFile.tsx +54 -0
- package/src/components/RoomComponents/styled/LastMessagePhoto.tsx +54 -0
- package/src/components/RoomComponents/styled/LastMessageVideo.tsx +70 -0
- package/src/components/RoomComponents/styled/LastTextMessage.tsx +65 -0
- package/src/components/RoomComponents/styled/StyledRoomComponents.ts +53 -0
- package/src/components/SortDropDown/index.tsx +76 -0
- package/src/components/Thread/ThreadHeader.tsx +41 -0
- package/src/components/Thread/ThreadWrapper.tsx +270 -0
- package/src/components/Toast/Toast.tsx +128 -0
- package/src/components/Toast/index.ts +13 -0
- package/src/components/UsersList/StyledComponents.ts +30 -0
- package/src/components/UsersList/UsersList.tsx +112 -0
- package/src/components/styled/ActionButton.tsx +40 -0
- package/src/components/styled/AudioMessage.tsx +82 -0
- package/src/components/styled/Button.tsx +107 -0
- package/src/components/styled/ChatWrapperBox.tsx +9 -0
- package/src/components/styled/DateLabel.tsx +77 -0
- package/src/components/styled/Loader.tsx +65 -0
- package/src/components/styled/MediaFilePreview.tsx +42 -0
- package/src/components/styled/MediaModal.tsx +54 -0
- package/src/components/styled/MessageImage.tsx +54 -0
- package/src/components/styled/NewMessageLabel.tsx +50 -0
- package/src/components/styled/RoomListComponents/index.tsx +164 -0
- package/src/components/styled/SendInput.tsx +297 -0
- package/src/components/styled/StyledComponents.ts +320 -0
- package/src/components/styled/StyledInput.tsx +101 -0
- package/src/components/styled/StyledInputComponents/AudioComponents.tsx +1 -0
- package/src/components/styled/StyledInputComponents/Composing.tsx +97 -0
- package/src/components/styled/StyledInputComponents/CustomTypingIndicator.tsx +261 -0
- package/src/components/styled/StyledInputComponents/MediaComponents.tsx +90 -0
- package/src/components/styled/StyledInputComponents/StyledInputComponents.tsx +131 -0
- package/src/components/styled/StyledInputComponents/VideoComponents.tsx +49 -0
- package/src/components/styled/TreadLabel.tsx +50 -0
- package/src/components/styled/UnsupportedType.tsx +95 -0
- package/src/components/styled/VideoMessage.tsx +68 -0
- package/src/context/MessageNotificationContext.tsx +335 -0
- package/src/context/PushNotificationProvider.tsx +78 -0
- package/src/context/ToastContext.tsx +63 -0
- package/src/context/toastProvider.tsx +0 -0
- package/src/context/xmppProvider.tsx +364 -0
- package/src/helpers/block_scroll.ts +95 -0
- package/src/helpers/chatAutoEnterer.ts +46 -0
- package/src/helpers/checkUniqueUsers.tsx +31 -0
- package/src/helpers/constants/CHAT_TYPES.ts +6 -0
- package/src/helpers/constants/LANGUAGE_OPTIONS.ts +14 -0
- package/src/helpers/constants/LOCAL_STORAGE.ts +3 -0
- package/src/helpers/constants/MESSAGE_INTERACTIONS.ts +29 -0
- package/src/helpers/constants/MODAL_TYPES.ts +57 -0
- package/src/helpers/constants/PLATFORM_CONSTANTS.ts +3 -0
- package/src/helpers/createMainMessageForThread.ts +23 -0
- package/src/helpers/createMessageFromXml.ts +118 -0
- package/src/helpers/createRoomFromApi.tsx +27 -0
- package/src/helpers/createUserNameFromSetUser.ts +15 -0
- package/src/helpers/dateComparison.ts +12 -0
- package/src/helpers/debounce.ts +10 -0
- package/src/helpers/ensureScopedChatCache.ts +61 -0
- package/src/helpers/extractUniqueMembersFromRooms.ts +45 -0
- package/src/helpers/formatNumberWithCommas.ts +3 -0
- package/src/helpers/getBooleanFromString.ts +7 -0
- package/src/helpers/getDataFromXml.ts +80 -0
- package/src/helpers/getNumberFromString.ts +5 -0
- package/src/helpers/getRoomsWithRetry.ts +45 -0
- package/src/helpers/getTintedColor.ts +28 -0
- package/src/helpers/getUnnamedUsers.ts +39 -0
- package/src/helpers/handleCopyClick.ts +3 -0
- package/src/helpers/handleXmppError.ts +14 -0
- package/src/helpers/hashcolor.ts +34 -0
- package/src/helpers/historyPreloadScheduler.ts +264 -0
- package/src/helpers/initRoomsPresence.ts +32 -0
- package/src/helpers/initXmppRooms.tsx +71 -0
- package/src/helpers/insertMessageWithDelimiter.ts +96 -0
- package/src/helpers/isChatIdPresentInArray.ts +54 -0
- package/src/helpers/localStorageUser.ts +9 -0
- package/src/helpers/markdownParser.tsx +295 -0
- package/src/helpers/nanoToMs.ts +3 -0
- package/src/helpers/parseMessageBody.tsx +516 -0
- package/src/helpers/parseUrls.tsx +42 -0
- package/src/helpers/resolveInitBeforeLoadUser.ts +240 -0
- package/src/helpers/storeConsole.ts +26 -0
- package/src/helpers/transformTranslatations.ts +16 -0
- package/src/helpers/updateMessagesTillLast.tsx +104 -0
- package/src/helpers/updatedChatLastTimestamps.ts +29 -0
- package/src/helpers/validator.ts +20 -0
- package/src/helpers/walletUsername.ts +12 -0
- package/src/hooks/hooks.ts +6 -0
- package/src/hooks/useChatSettingState.tsx +38 -0
- package/src/hooks/useChatWrapperInit.ts +266 -0
- package/src/hooks/useComposing.tsx +59 -0
- package/src/hooks/useCustomTypingIndicator.tsx +193 -0
- package/src/hooks/useEventHandlers.tsx +81 -0
- package/src/hooks/useGetNewArchRoom.tsx +57 -0
- package/src/hooks/useHeapSender.tsx +88 -0
- package/src/hooks/useLocalStorage.tsx +53 -0
- package/src/hooks/useLogout.tsx +31 -0
- package/src/hooks/useMessageHeapState.tsx +11 -0
- package/src/hooks/useMessageLoaderQueue.tsx +90 -0
- package/src/hooks/useMessageQueue.ts +146 -0
- package/src/hooks/usePendingNotification.ts +49 -0
- package/src/hooks/usePrevious.tsx +15 -0
- package/src/hooks/usePushNotifications.ts +106 -0
- package/src/hooks/useQRCodeChatHandler.ts +58 -0
- package/src/hooks/useRoomInitialization.tsx +160 -0
- package/src/hooks/useRoomState.tsx +47 -0
- package/src/hooks/useRoomUrl.tsx +41 -0
- package/src/hooks/useSendMessage.tsx +306 -0
- package/src/hooks/useUnreadMessagesCounter.ts +55 -0
- package/src/hooks/useXmppInitialization.ts +148 -0
- package/src/main.ts +45 -0
- package/src/networking/api-requests/auth.api.ts +140 -0
- package/src/networking/api-requests/push.api.ts +55 -0
- package/src/networking/api-requests/roomMembers.api.ts +20 -0
- package/src/networking/api-requests/rooms.api.ts +142 -0
- package/src/networking/api-requests/user.api.ts +65 -0
- package/src/networking/apiClient.ts +149 -0
- package/src/networking/helpers/refreshChecker.ts +13 -0
- package/src/networking/stanzaHandlers.ts +418 -0
- package/src/networking/xmpp/actionSetTimestampToPrivateStore.xmpp.ts +37 -0
- package/src/networking/xmpp/allRoomPresences.xmpp.ts +10 -0
- package/src/networking/xmpp/createPrivateRoom.xmpp.ts +26 -0
- package/src/networking/xmpp/createRoom.xmpp.ts +35 -0
- package/src/networking/xmpp/createRoomPresence.xmpp.ts +74 -0
- package/src/networking/xmpp/createTimeoutPromise.xmpp.ts +15 -0
- package/src/networking/xmpp/deleteMessage.xmpp.ts +19 -0
- package/src/networking/xmpp/editMessage.xmpp.ts +46 -0
- package/src/networking/xmpp/getChatsPrivateStoreRequest.xmpp.ts +57 -0
- package/src/networking/xmpp/getHistory.xmpp.ts +140 -0
- package/src/networking/xmpp/getLastMessageArchive.xmpp.ts +24 -0
- package/src/networking/xmpp/getRoomInfo.xmpp.ts +15 -0
- package/src/networking/xmpp/getRoomMembers.xmpp.ts +13 -0
- package/src/networking/xmpp/getRooms.xmpp.ts +43 -0
- package/src/networking/xmpp/getRoomsPaged.xmpp.ts +59 -0
- package/src/networking/xmpp/handlePong.xmpp.ts +7 -0
- package/src/networking/xmpp/handleStanzas.xmpp.ts +55 -0
- package/src/networking/xmpp/inviteRoomRequest.xmpp.ts +25 -0
- package/src/networking/xmpp/leaveTheRoom.xmpp.ts +15 -0
- package/src/networking/xmpp/listenerManager.ts +116 -0
- package/src/networking/xmpp/presenceInRoom.xmpp.ts +57 -0
- package/src/networking/xmpp/roomConfig.xmpp.ts +71 -0
- package/src/networking/xmpp/sendMediaMessage.xmpp.ts +97 -0
- package/src/networking/xmpp/sendMessageReaction.xmpp.ts +41 -0
- package/src/networking/xmpp/sendPing.xmpp.ts +21 -0
- package/src/networking/xmpp/sendTextMessage.xmpp.ts +99 -0
- package/src/networking/xmpp/sendTextMessageWithTranslateTag.xmpp.ts +44 -0
- package/src/networking/xmpp/sendTypingRequest.xmpp.ts +26 -0
- package/src/networking/xmpp/setChatsPrivateStoreRequest.xmpp.ts +48 -0
- package/src/networking/xmpp/setMeAsOwner.xmpp.ts +52 -0
- package/src/networking/xmpp/setRoomImage.xmpp.ts +26 -0
- package/src/networking/xmpp/setVCard.xmpp.ts +19 -0
- package/src/networking/xmpp/subscribeToRoomMessages.xmpp.ts +75 -0
- package/src/networking/xmppClient.ts +603 -0
- package/src/roomStore/Middleware/logoutMiddleware.tsx +24 -0
- package/src/roomStore/Middleware/newMessageMidlleware.tsx +87 -0
- package/src/roomStore/Middleware/reactionsMiddleware.tsx +77 -0
- package/src/roomStore/Middleware/testMiddleware.tsx +20 -0
- package/src/roomStore/Middleware/unreadMidlleware.tsx +58 -0
- package/src/roomStore/chatSettingsSlice.ts +178 -0
- package/src/roomStore/index.ts +68 -0
- package/src/roomStore/persistence.ts +152 -0
- package/src/roomStore/roomHeapSlice.ts +37 -0
- package/src/roomStore/roomsSlice.ts +353 -0
- package/src/services/pushNotifications.ts +170 -0
- package/src/services/pushSubscriptionService.ts +145 -0
- package/src/types/messages.ts +61 -0
- package/src/types/models/action.model.ts +30 -0
- package/src/types/models/config.model.ts +16 -0
- package/src/types/models/customComponents.model.ts +53 -0
- package/src/types/models/language.model.ts +11 -0
- package/src/types/models/media.model.ts +5 -0
- package/src/types/models/message.model.ts +69 -0
- package/src/types/models/modal.model.ts +9 -0
- package/src/types/models/room.model.ts +120 -0
- package/src/types/models/user.model.ts +90 -0
- package/src/types/models/xmpp.model.ts +155 -0
- package/src/types/types.ts +505 -0
- package/src/utils/PriorityQueue.ts +47 -0
- package/src/utils/actionHelpers.ts +40 -0
- package/src/utils/actionLogger.ts +64 -0
- package/src/utils/clientRegistry.ts +80 -0
- package/src/utils/devLogger.ts +197 -0
- package/src/utils/messageNotificationManager.ts +108 -0
- package/src/utils/resendMessage.ts +87 -0
- package/src/utils/toastEmitter.ts +27 -0
- package/src/utils/xmppMemoryMonitor.ts +63 -0
- package/src/version.ts +1 -0
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
/* eslint-disable react-hooks/rules-of-hooks -- pre-existing port artifacts; hooks called conditionally / inside helpers. TODO: refactor */
|
|
2
|
+
import React, { FC, useMemo, useState } from 'react';
|
|
3
|
+
import { View, Text, TouchableOpacity, Animated } from 'react-native';
|
|
4
|
+
import styled from 'styled-components/native';
|
|
5
|
+
import { ReactionMessage } from '../../types/types';
|
|
6
|
+
|
|
7
|
+
const ReactionContainer = styled.View`
|
|
8
|
+
flex-direction: row;
|
|
9
|
+
align-items: center;
|
|
10
|
+
gap: 8px;
|
|
11
|
+
`;
|
|
12
|
+
|
|
13
|
+
const ReactionBox = styled(TouchableOpacity)<{ active: boolean; color: string }>`
|
|
14
|
+
padding: 4px 8px;
|
|
15
|
+
border-radius: 20px;
|
|
16
|
+
background-color: ${({ active, color }) => (active ? color : '#ffffff')};
|
|
17
|
+
flex-direction: row;
|
|
18
|
+
align-items: center;
|
|
19
|
+
justify-content: center;
|
|
20
|
+
elevation: 3;
|
|
21
|
+
`;
|
|
22
|
+
|
|
23
|
+
interface MessageReactionProps {
|
|
24
|
+
color: string;
|
|
25
|
+
reaction: Record<string, ReactionMessage>;
|
|
26
|
+
changeReaction: (reaction: string) => void;
|
|
27
|
+
userName?: string;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const emojiMap: Record<string, string> = {
|
|
31
|
+
joy: '😂',
|
|
32
|
+
heart: '❤️',
|
|
33
|
+
fire: '🔥',
|
|
34
|
+
'+1': '👍',
|
|
35
|
+
smile: '😄',
|
|
36
|
+
scream: '😱',
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
export const MessageReaction: FC<MessageReactionProps> = ({
|
|
40
|
+
reaction,
|
|
41
|
+
color,
|
|
42
|
+
changeReaction,
|
|
43
|
+
userName,
|
|
44
|
+
}) => {
|
|
45
|
+
const [tooltipEmoji, setTooltipEmoji] = useState<string | null>(null);
|
|
46
|
+
const fadeAnim = new Animated.Value(0);
|
|
47
|
+
|
|
48
|
+
const showTooltip = (emoji: string) => {
|
|
49
|
+
setTooltipEmoji(emoji);
|
|
50
|
+
Animated.timing(fadeAnim, {
|
|
51
|
+
toValue: 1,
|
|
52
|
+
duration: 100,
|
|
53
|
+
useNativeDriver: true,
|
|
54
|
+
}).start();
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
const hideTooltip = () => {
|
|
58
|
+
Animated.timing(fadeAnim, {
|
|
59
|
+
toValue: 0,
|
|
60
|
+
duration: 100,
|
|
61
|
+
useNativeDriver: true,
|
|
62
|
+
}).start(() => setTooltipEmoji(null));
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
if (!reaction) {return null;}
|
|
66
|
+
|
|
67
|
+
const reactionDetails = useMemo(() => {
|
|
68
|
+
const result: Record<string, { count: number; users: string[] }> = {};
|
|
69
|
+
|
|
70
|
+
Object.values(reaction).forEach(({ emoji, data }) => {
|
|
71
|
+
if (emoji && emoji.length > 0)
|
|
72
|
+
{emoji.forEach((em) => {
|
|
73
|
+
if (!result[em]) {
|
|
74
|
+
result[em] = { count: 0, users: [] };
|
|
75
|
+
}
|
|
76
|
+
result[em].count += 1;
|
|
77
|
+
result[em].users.push(`${data.senderFirstName} ${data.senderLastName}`);
|
|
78
|
+
});}
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
return result;
|
|
82
|
+
}, [reaction]);
|
|
83
|
+
|
|
84
|
+
return (
|
|
85
|
+
<ReactionContainer>
|
|
86
|
+
{Object.entries(reactionDetails).map(([emoji, details]) => {
|
|
87
|
+
const isUserReacted = userName
|
|
88
|
+
? details.users.includes(userName)
|
|
89
|
+
: false;
|
|
90
|
+
|
|
91
|
+
return (
|
|
92
|
+
<View key={emoji} style={{ position: 'relative' }}>
|
|
93
|
+
<ReactionBox
|
|
94
|
+
active={isUserReacted}
|
|
95
|
+
color={color}
|
|
96
|
+
onPress={() => changeReaction(emoji)}
|
|
97
|
+
onLongPress={() => showTooltip(emoji)}
|
|
98
|
+
onPressOut={hideTooltip}
|
|
99
|
+
>
|
|
100
|
+
<Text style={{ fontSize: 18, marginRight: 4 }}>
|
|
101
|
+
{emojiMap[emoji] || emoji}
|
|
102
|
+
</Text>
|
|
103
|
+
<Text
|
|
104
|
+
style={{
|
|
105
|
+
fontSize: 14,
|
|
106
|
+
fontWeight: '600',
|
|
107
|
+
color: isUserReacted ? '#fff' : color,
|
|
108
|
+
}}
|
|
109
|
+
>
|
|
110
|
+
{details.count}
|
|
111
|
+
</Text>
|
|
112
|
+
</ReactionBox>
|
|
113
|
+
|
|
114
|
+
{/* Tooltip */}
|
|
115
|
+
{tooltipEmoji === emoji && (
|
|
116
|
+
<Animated.View
|
|
117
|
+
style={{
|
|
118
|
+
position: 'absolute',
|
|
119
|
+
bottom: 36,
|
|
120
|
+
left: '50%',
|
|
121
|
+
transform: [
|
|
122
|
+
{ translateX: -50 },
|
|
123
|
+
{
|
|
124
|
+
translateY: fadeAnim.interpolate({
|
|
125
|
+
inputRange: [0, 1],
|
|
126
|
+
outputRange: [4, 0],
|
|
127
|
+
}),
|
|
128
|
+
},
|
|
129
|
+
],
|
|
130
|
+
opacity: fadeAnim,
|
|
131
|
+
backgroundColor: '#333',
|
|
132
|
+
borderRadius: 6,
|
|
133
|
+
paddingHorizontal: 10,
|
|
134
|
+
paddingVertical: 6,
|
|
135
|
+
maxWidth: 220,
|
|
136
|
+
zIndex: 999,
|
|
137
|
+
}}
|
|
138
|
+
>
|
|
139
|
+
<Text style={{ color: '#fff', fontSize: 12 }}>
|
|
140
|
+
{details.users.join(', ')}
|
|
141
|
+
</Text>
|
|
142
|
+
</Animated.View>
|
|
143
|
+
)}
|
|
144
|
+
</View>
|
|
145
|
+
);
|
|
146
|
+
})}
|
|
147
|
+
</ReactionContainer>
|
|
148
|
+
);
|
|
149
|
+
};
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { FC } from 'react';
|
|
2
|
+
import { IMessage } from '../../types/types';
|
|
3
|
+
import { styled } from 'styled-components/native';
|
|
4
|
+
import { Text } from 'react-native';
|
|
5
|
+
|
|
6
|
+
export const StyledMessageReply = styled.TouchableOpacity<{
|
|
7
|
+
isUser: boolean;
|
|
8
|
+
configColor: string;
|
|
9
|
+
}>`
|
|
10
|
+
background-color: ${(props) => (props.isUser ? '#ffffff' : '#E7EDF9')};
|
|
11
|
+
padding: 8px 16px;
|
|
12
|
+
margin-bottom: 8px;
|
|
13
|
+
border-radius: 4px;
|
|
14
|
+
border-style: solid;
|
|
15
|
+
border-start-width: ${(props) => (props.isUser ? 4 : 0)}px;
|
|
16
|
+
border-start-color: ${(props) =>
|
|
17
|
+
props.isUser ? props.configColor : 'transparent'};
|
|
18
|
+
border-end-width: ${(props) => (!props.isUser ? 4 : 0)}px;
|
|
19
|
+
border-end-color: ${(props) =>
|
|
20
|
+
!props.isUser ? props.configColor : 'transparent'};
|
|
21
|
+
`;
|
|
22
|
+
|
|
23
|
+
const StyledText = styled.Text`
|
|
24
|
+
font-size: 14px;
|
|
25
|
+
overflow: hidden;
|
|
26
|
+
`;
|
|
27
|
+
|
|
28
|
+
interface MessageReplyProps {
|
|
29
|
+
isUser: boolean;
|
|
30
|
+
text: string;
|
|
31
|
+
color?: string;
|
|
32
|
+
handleReplyMessage: () => void;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export const MessageReply: FC<MessageReplyProps> = ({
|
|
36
|
+
isUser,
|
|
37
|
+
text,
|
|
38
|
+
color = '#0052CD',
|
|
39
|
+
handleReplyMessage,
|
|
40
|
+
}) => {
|
|
41
|
+
return (
|
|
42
|
+
<StyledMessageReply
|
|
43
|
+
onPress={handleReplyMessage}
|
|
44
|
+
isUser={isUser}
|
|
45
|
+
configColor={color}
|
|
46
|
+
>
|
|
47
|
+
<StyledText>{text}</StyledText>
|
|
48
|
+
</StyledMessageReply>
|
|
49
|
+
);
|
|
50
|
+
};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import React, { FC } from 'react';
|
|
2
|
+
import { CustomDivider } from './CustomDivider';
|
|
3
|
+
import { IConfig, IMessage } from '../../types/types';
|
|
4
|
+
import { CustomMessageText } from '../styled/StyledComponents';
|
|
5
|
+
|
|
6
|
+
interface MessageTranslationsProps {
|
|
7
|
+
message: IMessage;
|
|
8
|
+
langSource?: string;
|
|
9
|
+
config?: IConfig;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
const MessageTranslations: FC<MessageTranslationsProps> = ({
|
|
13
|
+
message,
|
|
14
|
+
langSource,
|
|
15
|
+
config,
|
|
16
|
+
}) => {
|
|
17
|
+
return (
|
|
18
|
+
langSource &&
|
|
19
|
+
message.langSource && (
|
|
20
|
+
<>
|
|
21
|
+
<CustomDivider configColor={config?.colors?.primary} />
|
|
22
|
+
<CustomMessageText>
|
|
23
|
+
{message.translations?.[langSource]?.translatedText}
|
|
24
|
+
</CustomMessageText>
|
|
25
|
+
</>
|
|
26
|
+
)
|
|
27
|
+
);
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
export default MessageTranslations;
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import React, { useState } from 'react';
|
|
2
|
+
import Button from '../../styled/Button';
|
|
3
|
+
import { useSelector } from 'react-redux';
|
|
4
|
+
import { getActiveRoom, RootState } from '../../../roomStore';
|
|
5
|
+
import { useXmppClient } from '../../../context/xmppProvider';
|
|
6
|
+
import {
|
|
7
|
+
ActionButton,
|
|
8
|
+
CloseButton,
|
|
9
|
+
GroupContainer,
|
|
10
|
+
ModalBackground,
|
|
11
|
+
ModalContainer,
|
|
12
|
+
ModalTitle,
|
|
13
|
+
} from '../styledModalComponents';
|
|
14
|
+
import InputWithLabel from '../../styled/StyledInput';
|
|
15
|
+
import {
|
|
16
|
+
getRoomByName,
|
|
17
|
+
postAddRoomMember,
|
|
18
|
+
} from '../../../networking/api-requests/rooms.api';
|
|
19
|
+
import { addRoomViaApi } from '../../../roomStore/roomsSlice';
|
|
20
|
+
import { createRoomFromApi } from '../../../helpers/createRoomFromApi';
|
|
21
|
+
import { useChatSettingState } from '../../../hooks/useChatSettingState';
|
|
22
|
+
import { useAppDispatch } from '../../../hooks/hooks';
|
|
23
|
+
import { Text } from 'react-native';
|
|
24
|
+
import { useToast } from '../../../context/ToastContext';
|
|
25
|
+
|
|
26
|
+
const AddMembersModal: React.FC = () => {
|
|
27
|
+
const { config } = useChatSettingState();
|
|
28
|
+
const activeRoom = useSelector((state: RootState) => getActiveRoom(state));
|
|
29
|
+
|
|
30
|
+
const dispatch = useAppDispatch();
|
|
31
|
+
const { client } = useXmppClient();
|
|
32
|
+
const { showToast } = useToast();
|
|
33
|
+
|
|
34
|
+
const [isModalOpen, setIsModalOpen] = useState(false);
|
|
35
|
+
const [userName, setUserName] = useState('');
|
|
36
|
+
|
|
37
|
+
const handleOpenModal = () => setIsModalOpen(true);
|
|
38
|
+
const handleCloseModal = () => setIsModalOpen(false);
|
|
39
|
+
|
|
40
|
+
const validateRoomName = (name: string) => {
|
|
41
|
+
if (name.trim().length < 3) {
|
|
42
|
+
return 'Room name must be at least 3 characters.';
|
|
43
|
+
}
|
|
44
|
+
return '';
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
const handleAddUser = async () => {
|
|
48
|
+
try {
|
|
49
|
+
if(!activeRoom) {return;}
|
|
50
|
+
|
|
51
|
+
await postAddRoomMember({
|
|
52
|
+
chatName: activeRoom.jid.split('@')[0],
|
|
53
|
+
members: [userName],
|
|
54
|
+
});
|
|
55
|
+
handleCloseModal();
|
|
56
|
+
await client.inviteRoomRequestStanza(userName, activeRoom.jid);
|
|
57
|
+
|
|
58
|
+
const room = await getRoomByName(activeRoom.jid);
|
|
59
|
+
const createdRoom = createRoomFromApi(room, config?.xmppSettings?.conference);
|
|
60
|
+
if (createdRoom) {
|
|
61
|
+
dispatch(
|
|
62
|
+
addRoomViaApi({
|
|
63
|
+
room: createdRoom,
|
|
64
|
+
xmpp: client,
|
|
65
|
+
})
|
|
66
|
+
);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
showToast({
|
|
70
|
+
id: Date.now().toString(),
|
|
71
|
+
title: 'Success',
|
|
72
|
+
message: `${userName} has been added to the room.`,
|
|
73
|
+
type: 'success',
|
|
74
|
+
});
|
|
75
|
+
} catch (error) {
|
|
76
|
+
console.error('Failed to add user:', error);
|
|
77
|
+
showToast({
|
|
78
|
+
id: Date.now().toString(),
|
|
79
|
+
title: 'Error',
|
|
80
|
+
message: 'Failed to add user.',
|
|
81
|
+
type: 'error',
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
const handleUserNameChange = (text: string) => {
|
|
87
|
+
setUserName(text);
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
return (
|
|
91
|
+
<>
|
|
92
|
+
<ActionButton variant="filled" unstyled onPress={handleOpenModal}>
|
|
93
|
+
Add members
|
|
94
|
+
</ActionButton>
|
|
95
|
+
|
|
96
|
+
{isModalOpen && (
|
|
97
|
+
<ModalBackground>
|
|
98
|
+
<ModalContainer>
|
|
99
|
+
<CloseButton onPress={handleCloseModal}>
|
|
100
|
+
<Text style={{ fontSize: 24 }}>×</Text>
|
|
101
|
+
</CloseButton>
|
|
102
|
+
<ModalTitle>Add New Member</ModalTitle>
|
|
103
|
+
<GroupContainer
|
|
104
|
+
style={{
|
|
105
|
+
flexDirection: 'column',
|
|
106
|
+
position: 'relative',
|
|
107
|
+
width: '100%',
|
|
108
|
+
}}
|
|
109
|
+
>
|
|
110
|
+
<InputWithLabel
|
|
111
|
+
style={{ flex: 1 }}
|
|
112
|
+
id="userName"
|
|
113
|
+
value={userName}
|
|
114
|
+
onChange={handleUserNameChange}
|
|
115
|
+
placeholder="Enter User Id"
|
|
116
|
+
/>
|
|
117
|
+
</GroupContainer>
|
|
118
|
+
|
|
119
|
+
<GroupContainer>
|
|
120
|
+
<Button
|
|
121
|
+
onPress={handleCloseModal}
|
|
122
|
+
text={'Cancel'}
|
|
123
|
+
style={{ width: '100%' }}
|
|
124
|
+
unstyled
|
|
125
|
+
variant="outlined"
|
|
126
|
+
/>
|
|
127
|
+
<Button
|
|
128
|
+
onPress={handleAddUser}
|
|
129
|
+
text={'Add'}
|
|
130
|
+
style={{ width: '100%' }}
|
|
131
|
+
unstyled
|
|
132
|
+
variant="filled"
|
|
133
|
+
/>
|
|
134
|
+
</GroupContainer>
|
|
135
|
+
</ModalContainer>
|
|
136
|
+
</ModalBackground>
|
|
137
|
+
)}
|
|
138
|
+
</>
|
|
139
|
+
);
|
|
140
|
+
};
|
|
141
|
+
|
|
142
|
+
export default AddMembersModal;
|