@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,53 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import styled from 'styled-components/native';
|
|
3
|
+
|
|
4
|
+
export const LastRoomMessageContainer = styled.View`
|
|
5
|
+
display: flex;
|
|
6
|
+
flex: 1;
|
|
7
|
+
flex-direction: column;
|
|
8
|
+
align-items: flex-start;
|
|
9
|
+
margin-right: 8px;
|
|
10
|
+
`;
|
|
11
|
+
|
|
12
|
+
export const LastRoomMessageName = styled.Text`
|
|
13
|
+
font-weight: 600;
|
|
14
|
+
max-width: 190px;
|
|
15
|
+
`;
|
|
16
|
+
|
|
17
|
+
export const LastRoomMessageText = styled.Text`
|
|
18
|
+
max-width: 190px;
|
|
19
|
+
flex-shrink: 1;
|
|
20
|
+
flex-wrap: nowrap;
|
|
21
|
+
`;
|
|
22
|
+
|
|
23
|
+
export const NewMessageMarker = styled.View`
|
|
24
|
+
border-radius: 8px;
|
|
25
|
+
padding: 2px 2px;
|
|
26
|
+
font-weight: 600;
|
|
27
|
+
min-width: 24px;
|
|
28
|
+
min-height: 24px;
|
|
29
|
+
font-size: 14px;
|
|
30
|
+
display: flex;
|
|
31
|
+
justify-content: center;
|
|
32
|
+
align-items: center;
|
|
33
|
+
margin-left: auto;
|
|
34
|
+
`;
|
|
35
|
+
|
|
36
|
+
export const LastMessageImg = styled.Image`
|
|
37
|
+
width: 20px;
|
|
38
|
+
height: 20px;
|
|
39
|
+
resize-mode: cover;
|
|
40
|
+
pointer-events: none;
|
|
41
|
+
`;
|
|
42
|
+
|
|
43
|
+
export const ShadeWrapper = styled.View`
|
|
44
|
+
width: 100%;
|
|
45
|
+
height: 100%;
|
|
46
|
+
position: relative;
|
|
47
|
+
top: 0;
|
|
48
|
+
left: 0;
|
|
49
|
+
right: 0;
|
|
50
|
+
bottom: 0;
|
|
51
|
+
background-color: rgba(0, 0, 0, 0.5);
|
|
52
|
+
z-index: 1;
|
|
53
|
+
`;
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import React, { useState } from 'react';
|
|
2
|
+
import styled from 'styled-components/native';
|
|
3
|
+
|
|
4
|
+
interface DropdownProps {
|
|
5
|
+
sortFunction: (value: string) => void;
|
|
6
|
+
icon: string;
|
|
7
|
+
values: string[];
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
const DropdownContainer = styled.View`
|
|
11
|
+
position: relative;
|
|
12
|
+
display: inline-block;
|
|
13
|
+
`;
|
|
14
|
+
|
|
15
|
+
const DropdownButton = styled.TouchableOpacity`
|
|
16
|
+
background-color: transparent;
|
|
17
|
+
border: none;
|
|
18
|
+
cursor: pointer;
|
|
19
|
+
`;
|
|
20
|
+
|
|
21
|
+
const DropdownIcon = styled.Text`
|
|
22
|
+
margin-left: 5px;
|
|
23
|
+
`;
|
|
24
|
+
|
|
25
|
+
const DropdownList = styled.View`
|
|
26
|
+
position: absolute;
|
|
27
|
+
top: 100%;
|
|
28
|
+
left: 0;
|
|
29
|
+
z-index: 1;
|
|
30
|
+
list-style-type: none;
|
|
31
|
+
padding: 0;
|
|
32
|
+
margin: 0;
|
|
33
|
+
background-color: #fff;
|
|
34
|
+
border: 1px solid #ccc;
|
|
35
|
+
`;
|
|
36
|
+
|
|
37
|
+
const DropdownItem = styled.Text`
|
|
38
|
+
padding: 10px;
|
|
39
|
+
cursor: pointer;
|
|
40
|
+
|
|
41
|
+
&:hover {
|
|
42
|
+
background-color: #f2f2f2;
|
|
43
|
+
}
|
|
44
|
+
`;
|
|
45
|
+
|
|
46
|
+
const DropdownMenu: React.FC<DropdownProps> = ({
|
|
47
|
+
sortFunction,
|
|
48
|
+
icon,
|
|
49
|
+
values,
|
|
50
|
+
}) => {
|
|
51
|
+
const [isOpen, setIsOpen] = useState(false);
|
|
52
|
+
|
|
53
|
+
const handleItemClick = (value: string) => {
|
|
54
|
+
sortFunction(value);
|
|
55
|
+
setIsOpen(false);
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
return (
|
|
59
|
+
<DropdownContainer>
|
|
60
|
+
<DropdownButton onPress={() => setIsOpen(!isOpen)}>
|
|
61
|
+
{icon && <DropdownIcon>{icon}</DropdownIcon>}
|
|
62
|
+
</DropdownButton>
|
|
63
|
+
{isOpen && (
|
|
64
|
+
<DropdownList>
|
|
65
|
+
{values.map((value) => (
|
|
66
|
+
<DropdownItem key={value} onPress={() => handleItemClick(value)}>
|
|
67
|
+
{value}
|
|
68
|
+
</DropdownItem>
|
|
69
|
+
))}
|
|
70
|
+
</DropdownList>
|
|
71
|
+
)}
|
|
72
|
+
</DropdownContainer>
|
|
73
|
+
);
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
export default DropdownMenu;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { FC } from 'react';
|
|
2
|
+
import {
|
|
3
|
+
ChatContainerHeader,
|
|
4
|
+
ChatContainerHeaderLabel,
|
|
5
|
+
} from '../styled/StyledComponents';
|
|
6
|
+
import Button from '../styled/Button';
|
|
7
|
+
import { CloseIcon } from '../../assets/icons';
|
|
8
|
+
import { useDispatch } from 'react-redux';
|
|
9
|
+
import { setCloseActiveMessage } from '../../roomStore/roomsSlice';
|
|
10
|
+
import { View } from 'react-native';
|
|
11
|
+
|
|
12
|
+
interface ThreadHeaderProps {
|
|
13
|
+
chatJID: string;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const ThreadHeader: FC<ThreadHeaderProps> = ({ chatJID }) => {
|
|
17
|
+
const dispatch = useDispatch();
|
|
18
|
+
|
|
19
|
+
const handleCloseThread = () => {
|
|
20
|
+
dispatch(setCloseActiveMessage({ chatJID: chatJID }));
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
return (
|
|
24
|
+
<ChatContainerHeader>
|
|
25
|
+
<View style={{ display: 'flex', gap: 8 }}>
|
|
26
|
+
<ChatContainerHeaderLabel>Thread</ChatContainerHeaderLabel>
|
|
27
|
+
</View>
|
|
28
|
+
|
|
29
|
+
<View style={{ display: 'flex', gap: 16 }}>
|
|
30
|
+
<Button
|
|
31
|
+
style={{ padding: 8 }}
|
|
32
|
+
EndIcon={<CloseIcon />}
|
|
33
|
+
unstyled
|
|
34
|
+
onPress={handleCloseThread}
|
|
35
|
+
/>
|
|
36
|
+
</View>
|
|
37
|
+
</ChatContainerHeader>
|
|
38
|
+
);
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
export default ThreadHeader;
|
|
@@ -0,0 +1,270 @@
|
|
|
1
|
+
import { FC, useCallback, useEffect, useRef, useState } from 'react';
|
|
2
|
+
import { IMessage, User } from '../../types/types';
|
|
3
|
+
import {
|
|
4
|
+
AlsoCheckbox,
|
|
5
|
+
AlsoContainer,
|
|
6
|
+
ChatContainer,
|
|
7
|
+
ThreadContainer,
|
|
8
|
+
} from '../styled/StyledComponents';
|
|
9
|
+
import SendInput from '../styled/SendInput';
|
|
10
|
+
import { useDispatch } from 'react-redux';
|
|
11
|
+
import { useXmppClient } from '../../context/xmppProvider';
|
|
12
|
+
import MessageList from '../MainComponents/MessageList';
|
|
13
|
+
import ModalHeaderComponent from '../Modals/ModalHeaderComponent';
|
|
14
|
+
import {
|
|
15
|
+
deleteRoomMessage,
|
|
16
|
+
setCloseActiveMessage,
|
|
17
|
+
setEditAction,
|
|
18
|
+
setLastViewedTimestamp,
|
|
19
|
+
} from '../../roomStore/roomsSlice';
|
|
20
|
+
import { EditWrapper } from '../MainComponents/EditWrapper';
|
|
21
|
+
import { useSendMessage } from '../../hooks/useSendMessage';
|
|
22
|
+
import { createMainMessageForThread } from '../../helpers/createMainMessageForThread';
|
|
23
|
+
import { useRoomState } from '../../hooks/useRoomState';
|
|
24
|
+
import { useChatSettingState } from '../../hooks/useChatSettingState';
|
|
25
|
+
import {
|
|
26
|
+
Animated,
|
|
27
|
+
Text,
|
|
28
|
+
TouchableOpacity,
|
|
29
|
+
StyleSheet,
|
|
30
|
+
PanResponder,
|
|
31
|
+
} from 'react-native';
|
|
32
|
+
import CustomTypingIndicator from '../styled/StyledInputComponents/CustomTypingIndicator';
|
|
33
|
+
|
|
34
|
+
interface ThreadWrapperProps {
|
|
35
|
+
activeMessage: IMessage;
|
|
36
|
+
user: User;
|
|
37
|
+
customMessageComponent?: React.ComponentType<{
|
|
38
|
+
message: IMessage;
|
|
39
|
+
isUser: boolean;
|
|
40
|
+
isReply: boolean;
|
|
41
|
+
}>;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
const ThreadWrapper: FC<ThreadWrapperProps> = ({
|
|
45
|
+
activeMessage,
|
|
46
|
+
user,
|
|
47
|
+
customMessageComponent: CustomMessageComponent,
|
|
48
|
+
}) => {
|
|
49
|
+
const { client } = useXmppClient();
|
|
50
|
+
const dispatch = useDispatch();
|
|
51
|
+
|
|
52
|
+
const { loading, roomsList, editAction, activeRoomJID } = useRoomState();
|
|
53
|
+
const { config } = useChatSettingState();
|
|
54
|
+
const { sendMessage: sendMs, sendMedia: sendMessageMedia, sendEditMessage, isLastMessageFromUserAndProcessing } = useSendMessage();
|
|
55
|
+
|
|
56
|
+
const [isLoadingMore, setIsLoadingMore] = useState<boolean>(false);
|
|
57
|
+
const [isChecked, setIsChecked] = useState<boolean>(false);
|
|
58
|
+
|
|
59
|
+
const slideAnim = useRef(new Animated.Value(300)).current;
|
|
60
|
+
|
|
61
|
+
const panResponder = useRef(
|
|
62
|
+
PanResponder.create({
|
|
63
|
+
onStartShouldSetPanResponder: (e, gestureState) => {
|
|
64
|
+
return gestureState.x0 <= 100;
|
|
65
|
+
},
|
|
66
|
+
onMoveShouldSetPanResponder: (e, gestureState) => {
|
|
67
|
+
return gestureState.x0 <= 100 && gestureState.dx > 0;
|
|
68
|
+
},
|
|
69
|
+
onPanResponderMove: (e, gestureState) => {
|
|
70
|
+
if (gestureState.x0 <= 100 && gestureState.dx > 0) {
|
|
71
|
+
slideAnim.setValue(gestureState.dx);
|
|
72
|
+
}
|
|
73
|
+
},
|
|
74
|
+
onPanResponderRelease: (e, gestureState) => {
|
|
75
|
+
if (gestureState.x0 <= 100 && gestureState.dx > 150) {
|
|
76
|
+
closeThread();
|
|
77
|
+
} else {
|
|
78
|
+
Animated.spring(slideAnim, {
|
|
79
|
+
toValue: 0,
|
|
80
|
+
useNativeDriver: true,
|
|
81
|
+
}).start();
|
|
82
|
+
}
|
|
83
|
+
},
|
|
84
|
+
})
|
|
85
|
+
).current;
|
|
86
|
+
|
|
87
|
+
const loadMoreMessages = useCallback(
|
|
88
|
+
async (chatJID: string, max: number, idOfMessageBefore?: number) => {
|
|
89
|
+
if (!isLoadingMore) {
|
|
90
|
+
client?.getHistoryStanza(chatJID, max, idOfMessageBefore).then(() => {
|
|
91
|
+
setIsLoadingMore(false);
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
},
|
|
95
|
+
[client]
|
|
96
|
+
);
|
|
97
|
+
|
|
98
|
+
const sendMessage = useCallback(
|
|
99
|
+
(message: string) => {
|
|
100
|
+
sendMs(
|
|
101
|
+
message,
|
|
102
|
+
activeMessage.roomJid,
|
|
103
|
+
true,
|
|
104
|
+
isChecked,
|
|
105
|
+
createMainMessageForThread(activeMessage)
|
|
106
|
+
);
|
|
107
|
+
},
|
|
108
|
+
[activeMessage, isChecked]
|
|
109
|
+
);
|
|
110
|
+
|
|
111
|
+
const sendMedia = useCallback(
|
|
112
|
+
(data: any, type: string) => {
|
|
113
|
+
sendMessageMedia(
|
|
114
|
+
data,
|
|
115
|
+
type,
|
|
116
|
+
activeMessage.roomJid,
|
|
117
|
+
true,
|
|
118
|
+
isChecked,
|
|
119
|
+
createMainMessageForThread(activeMessage)
|
|
120
|
+
);
|
|
121
|
+
},
|
|
122
|
+
[activeMessage, isChecked]
|
|
123
|
+
);
|
|
124
|
+
|
|
125
|
+
const sendStartComposing = useCallback(() => {
|
|
126
|
+
if (config?.disableTypingIndicator) {
|
|
127
|
+
return;
|
|
128
|
+
}
|
|
129
|
+
client.sendTypingRequestStanza(
|
|
130
|
+
activeMessage.roomJid,
|
|
131
|
+
`${user.firstName} ${user.lastName}`,
|
|
132
|
+
true
|
|
133
|
+
);
|
|
134
|
+
}, []);
|
|
135
|
+
|
|
136
|
+
const sendEndComposing = useCallback(() => {
|
|
137
|
+
if (config?.disableTypingIndicator) {
|
|
138
|
+
return;
|
|
139
|
+
}
|
|
140
|
+
client.sendTypingRequestStanza(
|
|
141
|
+
activeMessage.roomJid,
|
|
142
|
+
`${user.firstName} ${user.lastName}`,
|
|
143
|
+
false
|
|
144
|
+
);
|
|
145
|
+
}, []);
|
|
146
|
+
|
|
147
|
+
const onCloseEdit = () => {
|
|
148
|
+
dispatch(setEditAction({ isEdit: false }));
|
|
149
|
+
};
|
|
150
|
+
|
|
151
|
+
const closeThread = () => {
|
|
152
|
+
dispatch(setCloseActiveMessage({ chatJID: activeMessage.roomJid }));
|
|
153
|
+
dispatch(setEditAction({ isEdit: false }));
|
|
154
|
+
};
|
|
155
|
+
|
|
156
|
+
useEffect(() => {
|
|
157
|
+
if (activeMessage?.activeMessage) {
|
|
158
|
+
Animated.timing(slideAnim, {
|
|
159
|
+
toValue: 0,
|
|
160
|
+
duration: 300,
|
|
161
|
+
useNativeDriver: true,
|
|
162
|
+
}).start();
|
|
163
|
+
} else {
|
|
164
|
+
Animated.timing(slideAnim, {
|
|
165
|
+
toValue: 300,
|
|
166
|
+
duration: 300,
|
|
167
|
+
useNativeDriver: true,
|
|
168
|
+
}).start();
|
|
169
|
+
}
|
|
170
|
+
}, [activeMessage?.activeMessage]);
|
|
171
|
+
|
|
172
|
+
return (
|
|
173
|
+
<Animated.View
|
|
174
|
+
{...panResponder.panHandlers}
|
|
175
|
+
style={[
|
|
176
|
+
styles.threadContainer,
|
|
177
|
+
{ transform: [{ translateX: slideAnim }] },
|
|
178
|
+
// ...config?.chatRoomStyles,
|
|
179
|
+
]}
|
|
180
|
+
>
|
|
181
|
+
<ModalHeaderComponent
|
|
182
|
+
headerTitle="Thread"
|
|
183
|
+
handleCloseModal={closeThread}
|
|
184
|
+
/>
|
|
185
|
+
<MessageList
|
|
186
|
+
loadMoreMessages={loadMoreMessages}
|
|
187
|
+
CustomMessage={CustomMessageComponent}
|
|
188
|
+
user={user}
|
|
189
|
+
roomJID={activeMessage.roomJid}
|
|
190
|
+
config={config}
|
|
191
|
+
loading={isLoadingMore}
|
|
192
|
+
activeMessage={activeMessage}
|
|
193
|
+
isReply
|
|
194
|
+
/>
|
|
195
|
+
<AlsoContainer onPress={() => setIsChecked((prev) => !prev)}>
|
|
196
|
+
<AlsoCheckbox
|
|
197
|
+
accentColor={
|
|
198
|
+
isChecked ? config?.colors?.primary || '#0052CD' : '#fff'
|
|
199
|
+
}
|
|
200
|
+
// checked={isChecked}
|
|
201
|
+
// onPress={() => setIsChecked(!isChecked)}
|
|
202
|
+
/>
|
|
203
|
+
<Text>Also send to</Text>
|
|
204
|
+
<TouchableOpacity onPress={closeThread}>
|
|
205
|
+
<Text
|
|
206
|
+
style={{
|
|
207
|
+
color: config?.colors?.primary || '#0052CD',
|
|
208
|
+
fontWeight: 500,
|
|
209
|
+
}}
|
|
210
|
+
>
|
|
211
|
+
{roomsList[activeMessage.roomJid].name}
|
|
212
|
+
</Text>
|
|
213
|
+
</TouchableOpacity>
|
|
214
|
+
</AlsoContainer>
|
|
215
|
+
{editAction && editAction.isEdit && (
|
|
216
|
+
<EditWrapper text={editAction.text || ''} onClose={onCloseEdit} />
|
|
217
|
+
)}
|
|
218
|
+
<SendInput
|
|
219
|
+
editMessage={editAction && editAction.text}
|
|
220
|
+
sendMedia={sendMedia}
|
|
221
|
+
sendMessage={editAction && editAction.isEdit ? sendEditMessage : sendMessage}
|
|
222
|
+
config={config}
|
|
223
|
+
onFocus={sendStartComposing}
|
|
224
|
+
onBlur={sendEndComposing}
|
|
225
|
+
isLoading={loading}
|
|
226
|
+
isMessageProcessing={isLastMessageFromUserAndProcessing(
|
|
227
|
+
activeMessage.roomJid
|
|
228
|
+
)}
|
|
229
|
+
/>
|
|
230
|
+
|
|
231
|
+
{config?.customTypingIndicator?.enabled &&
|
|
232
|
+
(config.customTypingIndicator.position === 'overlay' ||
|
|
233
|
+
config.customTypingIndicator.position === 'floating') &&
|
|
234
|
+
roomsList[activeMessage.roomJid]?.composing && (
|
|
235
|
+
<CustomTypingIndicator
|
|
236
|
+
usersTyping={
|
|
237
|
+
roomsList[activeMessage.roomJid]?.composingList || ['User']
|
|
238
|
+
}
|
|
239
|
+
text={config.customTypingIndicator.text}
|
|
240
|
+
position={config.customTypingIndicator.position}
|
|
241
|
+
styles={config.customTypingIndicator.styles}
|
|
242
|
+
customComponent={config.customTypingIndicator.customComponent}
|
|
243
|
+
isVisible={roomsList[activeMessage.roomJid]?.composing || false}
|
|
244
|
+
/>
|
|
245
|
+
)}
|
|
246
|
+
</Animated.View>
|
|
247
|
+
);
|
|
248
|
+
};
|
|
249
|
+
|
|
250
|
+
export default ThreadWrapper;
|
|
251
|
+
|
|
252
|
+
const styles = StyleSheet.create({
|
|
253
|
+
threadContainer: {
|
|
254
|
+
zIndex: 999,
|
|
255
|
+
position: 'absolute',
|
|
256
|
+
top: 0,
|
|
257
|
+
bottom: 0,
|
|
258
|
+
right: 0,
|
|
259
|
+
width: '100%',
|
|
260
|
+
height: '100%',
|
|
261
|
+
backgroundColor: '#f3f6fc',
|
|
262
|
+
flexDirection: 'column',
|
|
263
|
+
justifyContent: 'space-between',
|
|
264
|
+
flex: 1,
|
|
265
|
+
},
|
|
266
|
+
text: {
|
|
267
|
+
color: '#fff',
|
|
268
|
+
fontSize: 18,
|
|
269
|
+
},
|
|
270
|
+
});
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import React, { useEffect, useRef } from 'react';
|
|
2
|
+
import { Animated } from 'react-native';
|
|
3
|
+
import styled, { css } from 'styled-components/native';
|
|
4
|
+
|
|
5
|
+
export interface ToastType {
|
|
6
|
+
id: string;
|
|
7
|
+
title: string;
|
|
8
|
+
message: string;
|
|
9
|
+
type: 'success' | 'error' | 'info';
|
|
10
|
+
duration?: number;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
const ToastContainer = styled(Animated.View)<{ type: string }>`
|
|
14
|
+
${({ type }) => {
|
|
15
|
+
let backgroundColor = '#333';
|
|
16
|
+
switch (type) {
|
|
17
|
+
case 'success':
|
|
18
|
+
backgroundColor = '#4caf50';
|
|
19
|
+
break;
|
|
20
|
+
case 'error':
|
|
21
|
+
backgroundColor = '#f44336';
|
|
22
|
+
break;
|
|
23
|
+
case 'info':
|
|
24
|
+
backgroundColor = '#2196F3';
|
|
25
|
+
break;
|
|
26
|
+
}
|
|
27
|
+
return css`
|
|
28
|
+
background-color: ${backgroundColor};
|
|
29
|
+
`;
|
|
30
|
+
}}
|
|
31
|
+
padding: 12px;
|
|
32
|
+
border-radius: 6px;
|
|
33
|
+
margin-bottom: 8px;
|
|
34
|
+
width: 240px;
|
|
35
|
+
shadow-color: #000;
|
|
36
|
+
shadow-offset: 0px 2px;
|
|
37
|
+
shadow-opacity: 0.2;
|
|
38
|
+
shadow-radius: 4px;
|
|
39
|
+
elevation: 3;
|
|
40
|
+
`;
|
|
41
|
+
|
|
42
|
+
const Title = styled.Text`
|
|
43
|
+
font-weight: bold;
|
|
44
|
+
color: white;
|
|
45
|
+
font-size: 15px;
|
|
46
|
+
`;
|
|
47
|
+
|
|
48
|
+
const Message = styled.Text`
|
|
49
|
+
color: white;
|
|
50
|
+
font-size: 13px;
|
|
51
|
+
margin-top: 4px;
|
|
52
|
+
`;
|
|
53
|
+
|
|
54
|
+
const ProgressBar = styled(Animated.View)`
|
|
55
|
+
position: absolute;
|
|
56
|
+
bottom: 0;
|
|
57
|
+
left: 0;
|
|
58
|
+
height: 3px;
|
|
59
|
+
background-color: rgba(255, 255, 255, 0.6);
|
|
60
|
+
`;
|
|
61
|
+
|
|
62
|
+
const Toast: React.FC<ToastType> = ({
|
|
63
|
+
title,
|
|
64
|
+
message,
|
|
65
|
+
type,
|
|
66
|
+
duration = 3000,
|
|
67
|
+
}) => {
|
|
68
|
+
const fadeAnim = useRef(new Animated.Value(0)).current;
|
|
69
|
+
const translateY = useRef(new Animated.Value(10)).current;
|
|
70
|
+
const progressAnim = useRef(new Animated.Value(1)).current;
|
|
71
|
+
|
|
72
|
+
useEffect(() => {
|
|
73
|
+
// Анимация появления и исчезновения
|
|
74
|
+
Animated.sequence([
|
|
75
|
+
Animated.parallel([
|
|
76
|
+
Animated.timing(fadeAnim, {
|
|
77
|
+
toValue: 1,
|
|
78
|
+
duration: 300,
|
|
79
|
+
useNativeDriver: true,
|
|
80
|
+
}),
|
|
81
|
+
Animated.timing(translateY, {
|
|
82
|
+
toValue: 0,
|
|
83
|
+
duration: 300,
|
|
84
|
+
useNativeDriver: true,
|
|
85
|
+
}),
|
|
86
|
+
Animated.timing(progressAnim, {
|
|
87
|
+
toValue: 0,
|
|
88
|
+
duration,
|
|
89
|
+
useNativeDriver: false,
|
|
90
|
+
}),
|
|
91
|
+
]),
|
|
92
|
+
Animated.delay(duration - 300),
|
|
93
|
+
Animated.parallel([
|
|
94
|
+
Animated.timing(fadeAnim, {
|
|
95
|
+
toValue: 0,
|
|
96
|
+
duration: 300,
|
|
97
|
+
useNativeDriver: true,
|
|
98
|
+
}),
|
|
99
|
+
Animated.timing(translateY, {
|
|
100
|
+
toValue: 10,
|
|
101
|
+
duration: 300,
|
|
102
|
+
useNativeDriver: true,
|
|
103
|
+
}),
|
|
104
|
+
]),
|
|
105
|
+
]).start();
|
|
106
|
+
}, [fadeAnim, translateY, progressAnim, duration]);
|
|
107
|
+
|
|
108
|
+
const progressWidth = progressAnim.interpolate({
|
|
109
|
+
inputRange: [0, 1],
|
|
110
|
+
outputRange: ['0%', '100%'],
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
return (
|
|
114
|
+
<ToastContainer
|
|
115
|
+
type={type}
|
|
116
|
+
style={{
|
|
117
|
+
opacity: fadeAnim,
|
|
118
|
+
transform: [{ translateY }],
|
|
119
|
+
}}
|
|
120
|
+
>
|
|
121
|
+
<Title>{title}</Title>
|
|
122
|
+
<Message>{message}</Message>
|
|
123
|
+
<ProgressBar style={{ width: progressWidth }} />
|
|
124
|
+
</ToastContainer>
|
|
125
|
+
);
|
|
126
|
+
};
|
|
127
|
+
|
|
128
|
+
export { Toast };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import styled from 'styled-components/native';
|
|
2
|
+
|
|
3
|
+
export const Notification = styled.View<{type: 'success' | 'error'}>`
|
|
4
|
+
padding: 10px 15px;
|
|
5
|
+
margin-top: 16px;
|
|
6
|
+
color: ${({type}) => (type === 'success' ? '#10b981' : '#ef4444')};
|
|
7
|
+
background: ${({type}) => (type === 'success' ? '#d1fae5' : '#fee2e2')};
|
|
8
|
+
border: 1px solid ${({type}) => (type === 'success' ? '#10b981' : '#ef4444')};
|
|
9
|
+
border-radius: 4px;
|
|
10
|
+
`;
|
|
11
|
+
|
|
12
|
+
export { Toast } from './Toast';
|
|
13
|
+
export type { ToastType } from './Toast';
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import styled from 'styled-components/native';
|
|
2
|
+
import CheckBox from '@react-native-community/checkbox';
|
|
3
|
+
|
|
4
|
+
export const ScrollableContainer = styled.View`
|
|
5
|
+
max-height: 100px;
|
|
6
|
+
overflow-y: auto;
|
|
7
|
+
width: 80%;
|
|
8
|
+
padding: 8px;
|
|
9
|
+
max-width: 80%;
|
|
10
|
+
`;
|
|
11
|
+
|
|
12
|
+
export const UserItem = styled.TouchableHighlight`
|
|
13
|
+
display: flex;
|
|
14
|
+
align-items: center;
|
|
15
|
+
padding: 8px;
|
|
16
|
+
border-bottom: 1px solid #f0f0f0;
|
|
17
|
+
gap: 8px;
|
|
18
|
+
`;
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
export const Checkbox = styled(CheckBox)`
|
|
22
|
+
width: 16px;
|
|
23
|
+
height: 16px;
|
|
24
|
+
tint-color: #0052cd;
|
|
25
|
+
`;
|
|
26
|
+
|
|
27
|
+
export const Label = styled.Text`
|
|
28
|
+
font-size: 16px;
|
|
29
|
+
color: #333;
|
|
30
|
+
`;
|