@ethora/chat-component-rn 26.7.4 → 26.7.5
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/CHANGELOG.md +0 -54
- package/README.md +8 -31
- package/lib/commonjs/assets/icons.js +2 -7
- package/lib/commonjs/assets/icons.js.map +1 -1
- package/lib/commonjs/components/Header/HeaderRoomList.js +6 -20
- package/lib/commonjs/components/Header/HeaderRoomList.js.map +1 -1
- package/lib/commonjs/components/MainComponents/ChatRoom.js +14 -36
- package/lib/commonjs/components/MainComponents/ChatRoom.js.map +1 -1
- package/lib/commonjs/components/MainComponents/MessageList.js +23 -7
- package/lib/commonjs/components/MainComponents/MessageList.js.map +1 -1
- package/lib/commonjs/components/MainComponents/ProfileImagePlaceholder.js +13 -14
- package/lib/commonjs/components/MainComponents/ProfileImagePlaceholder.js.map +1 -1
- package/lib/commonjs/components/MainComponents/RoomList.js +32 -62
- package/lib/commonjs/components/MainComponents/RoomList.js.map +1 -1
- package/lib/commonjs/components/Menu/HeaderRoomListMenu.js +98 -309
- package/lib/commonjs/components/Menu/HeaderRoomListMenu.js.map +1 -1
- package/lib/commonjs/components/Modals/AttachSheet/AttachSheet.js +110 -320
- package/lib/commonjs/components/Modals/AttachSheet/AttachSheet.js.map +1 -1
- package/lib/commonjs/components/Modals/ChatProfileModal/ChatProfileModal.js +213 -552
- package/lib/commonjs/components/Modals/ChatProfileModal/ChatProfileModal.js.map +1 -1
- package/lib/commonjs/components/Modals/FilePreviewModal/FilePreviewModal.js +2 -6
- package/lib/commonjs/components/Modals/FilePreviewModal/FilePreviewModal.js.map +1 -1
- package/lib/commonjs/components/Modals/Modal/Modal.js +0 -8
- package/lib/commonjs/components/Modals/Modal/Modal.js.map +1 -1
- package/lib/commonjs/components/Modals/NewChatModal/ModalContent.js +1 -2
- package/lib/commonjs/components/Modals/NewChatModal/ModalContent.js.map +1 -1
- package/lib/commonjs/components/Modals/NewChatModal/NewChatModal.js +104 -202
- package/lib/commonjs/components/Modals/NewChatModal/NewChatModal.js.map +1 -1
- package/lib/commonjs/components/Modals/NewChatModal/UpdNewChatModal.js +0 -8
- package/lib/commonjs/components/Modals/NewChatModal/UpdNewChatModal.js.map +1 -1
- package/lib/commonjs/components/Modals/SelectUsersModal/SelectUsersModal.js +2 -4
- package/lib/commonjs/components/Modals/SelectUsersModal/SelectUsersModal.js.map +1 -1
- package/lib/commonjs/components/Modals/UserProfileModal/EditUserModal.js +21 -7
- package/lib/commonjs/components/Modals/UserProfileModal/EditUserModal.js.map +1 -1
- package/lib/commonjs/components/Modals/UserProfileModal/UserProfileModal.js +244 -507
- package/lib/commonjs/components/Modals/UserProfileModal/UserProfileModal.js.map +1 -1
- package/lib/commonjs/components/Modals/UserSettingsModal/UserSettingsModal.js +46 -74
- package/lib/commonjs/components/Modals/UserSettingsModal/UserSettingsModal.js.map +1 -1
- package/lib/commonjs/components/Modals/styledModalComponents.js +2 -9
- package/lib/commonjs/components/Modals/styledModalComponents.js.map +1 -1
- package/lib/commonjs/components/RoomComponents/ChatRoomItem.js +7 -17
- package/lib/commonjs/components/RoomComponents/ChatRoomItem.js.map +1 -1
- package/lib/commonjs/components/styled/SendInput.js +11 -80
- package/lib/commonjs/components/styled/SendInput.js.map +1 -1
- package/lib/commonjs/components/styled/StyledComponents.js +3 -9
- package/lib/commonjs/components/styled/StyledComponents.js.map +1 -1
- package/lib/commonjs/components/styled/StyledInputComponents/StyledInputComponents.js +4 -11
- package/lib/commonjs/components/styled/StyledInputComponents/StyledInputComponents.js.map +1 -1
- package/lib/commonjs/context/xmppProvider.js +35 -6
- package/lib/commonjs/context/xmppProvider.js.map +1 -1
- package/lib/commonjs/helpers/updateMessagesTillLast.js +40 -12
- package/lib/commonjs/helpers/updateMessagesTillLast.js.map +1 -1
- package/lib/commonjs/hooks/useChatRoomFocus.js +9 -3
- package/lib/commonjs/hooks/useChatRoomFocus.js.map +1 -1
- package/lib/commonjs/hooks/useLogout.js +5 -0
- package/lib/commonjs/hooks/useLogout.js.map +1 -1
- package/lib/commonjs/hooks/useSendMessage.js +50 -23
- package/lib/commonjs/hooks/useSendMessage.js.map +1 -1
- package/lib/commonjs/i18n/strings.js +1 -121
- package/lib/commonjs/i18n/strings.js.map +1 -1
- package/lib/commonjs/main.js +0 -6
- package/lib/commonjs/main.js.map +1 -1
- package/lib/commonjs/networking/api-requests/user.api.js +0 -59
- package/lib/commonjs/networking/api-requests/user.api.js.map +1 -1
- package/lib/commonjs/networking/outboundQueue.js +18 -0
- package/lib/commonjs/networking/outboundQueue.js.map +1 -1
- package/lib/commonjs/networking/stanzaHandlers.js +10 -1
- package/lib/commonjs/networking/stanzaHandlers.js.map +1 -1
- package/lib/commonjs/networking/xmppClient.js +107 -7
- package/lib/commonjs/networking/xmppClient.js.map +1 -1
- package/lib/commonjs/roomStore/chatSettingsSlice.js +1 -3
- package/lib/commonjs/roomStore/chatSettingsSlice.js.map +1 -1
- package/lib/commonjs/roomStore/roomsSlice.js +22 -3
- package/lib/commonjs/roomStore/roomsSlice.js.map +1 -1
- package/lib/module/assets/icons.js +1 -6
- package/lib/module/assets/icons.js.map +1 -1
- package/lib/module/components/Header/HeaderRoomList.js +6 -20
- package/lib/module/components/Header/HeaderRoomList.js.map +1 -1
- package/lib/module/components/MainComponents/ChatRoom.js +14 -36
- package/lib/module/components/MainComponents/ChatRoom.js.map +1 -1
- package/lib/module/components/MainComponents/MessageList.js +24 -8
- package/lib/module/components/MainComponents/MessageList.js.map +1 -1
- package/lib/module/components/MainComponents/ProfileImagePlaceholder.js +13 -14
- package/lib/module/components/MainComponents/ProfileImagePlaceholder.js.map +1 -1
- package/lib/module/components/MainComponents/RoomList.js +32 -62
- package/lib/module/components/MainComponents/RoomList.js.map +1 -1
- package/lib/module/components/Menu/HeaderRoomListMenu.js +101 -311
- package/lib/module/components/Menu/HeaderRoomListMenu.js.map +1 -1
- package/lib/module/components/Modals/AttachSheet/AttachSheet.js +113 -311
- package/lib/module/components/Modals/AttachSheet/AttachSheet.js.map +1 -1
- package/lib/module/components/Modals/ChatProfileModal/ChatProfileModal.js +217 -555
- package/lib/module/components/Modals/ChatProfileModal/ChatProfileModal.js.map +1 -1
- package/lib/module/components/Modals/FilePreviewModal/FilePreviewModal.js +2 -6
- package/lib/module/components/Modals/FilePreviewModal/FilePreviewModal.js.map +1 -1
- package/lib/module/components/Modals/Modal/Modal.js +1 -9
- package/lib/module/components/Modals/Modal/Modal.js.map +1 -1
- package/lib/module/components/Modals/NewChatModal/ModalContent.js +1 -2
- package/lib/module/components/Modals/NewChatModal/ModalContent.js.map +1 -1
- package/lib/module/components/Modals/NewChatModal/NewChatModal.js +106 -205
- package/lib/module/components/Modals/NewChatModal/NewChatModal.js.map +1 -1
- package/lib/module/components/Modals/NewChatModal/UpdNewChatModal.js +0 -8
- package/lib/module/components/Modals/NewChatModal/UpdNewChatModal.js.map +1 -1
- package/lib/module/components/Modals/SelectUsersModal/SelectUsersModal.js +2 -4
- package/lib/module/components/Modals/SelectUsersModal/SelectUsersModal.js.map +1 -1
- package/lib/module/components/Modals/UserProfileModal/EditUserModal.js +23 -9
- package/lib/module/components/Modals/UserProfileModal/EditUserModal.js.map +1 -1
- package/lib/module/components/Modals/UserProfileModal/UserProfileModal.js +248 -509
- package/lib/module/components/Modals/UserProfileModal/UserProfileModal.js.map +1 -1
- package/lib/module/components/Modals/UserSettingsModal/UserSettingsModal.js +48 -76
- package/lib/module/components/Modals/UserSettingsModal/UserSettingsModal.js.map +1 -1
- package/lib/module/components/Modals/styledModalComponents.js +2 -9
- package/lib/module/components/Modals/styledModalComponents.js.map +1 -1
- package/lib/module/components/RoomComponents/ChatRoomItem.js +7 -17
- package/lib/module/components/RoomComponents/ChatRoomItem.js.map +1 -1
- package/lib/module/components/styled/SendInput.js +12 -81
- package/lib/module/components/styled/SendInput.js.map +1 -1
- package/lib/module/components/styled/StyledComponents.js +3 -9
- package/lib/module/components/styled/StyledComponents.js.map +1 -1
- package/lib/module/components/styled/StyledInputComponents/StyledInputComponents.js +4 -11
- package/lib/module/components/styled/StyledInputComponents/StyledInputComponents.js.map +1 -1
- package/lib/module/context/xmppProvider.js +35 -6
- package/lib/module/context/xmppProvider.js.map +1 -1
- package/lib/module/helpers/updateMessagesTillLast.js +41 -13
- package/lib/module/helpers/updateMessagesTillLast.js.map +1 -1
- package/lib/module/hooks/useChatRoomFocus.js +9 -3
- package/lib/module/hooks/useChatRoomFocus.js.map +1 -1
- package/lib/module/hooks/useLogout.js +5 -0
- package/lib/module/hooks/useLogout.js.map +1 -1
- package/lib/module/hooks/useSendMessage.js +51 -24
- package/lib/module/hooks/useSendMessage.js.map +1 -1
- package/lib/module/i18n/strings.js +1 -121
- package/lib/module/i18n/strings.js.map +1 -1
- package/lib/module/main.js +1 -1
- package/lib/module/main.js.map +1 -1
- package/lib/module/networking/api-requests/user.api.js +0 -56
- package/lib/module/networking/api-requests/user.api.js.map +1 -1
- package/lib/module/networking/outboundQueue.js +17 -0
- package/lib/module/networking/outboundQueue.js.map +1 -1
- package/lib/module/networking/stanzaHandlers.js +10 -1
- package/lib/module/networking/stanzaHandlers.js.map +1 -1
- package/lib/module/networking/xmppClient.js +107 -7
- package/lib/module/networking/xmppClient.js.map +1 -1
- package/lib/module/roomStore/chatSettingsSlice.js +1 -3
- package/lib/module/roomStore/chatSettingsSlice.js.map +1 -1
- package/lib/module/roomStore/roomsSlice.js +20 -2
- package/lib/module/roomStore/roomsSlice.js.map +1 -1
- package/lib/typescript/assets/icons.d.ts +0 -16
- package/lib/typescript/assets/icons.d.ts.map +1 -1
- package/lib/typescript/components/Header/HeaderRoomList.d.ts.map +1 -1
- package/lib/typescript/components/MainComponents/ChatRoom.d.ts.map +1 -1
- package/lib/typescript/components/MainComponents/MessageList.d.ts.map +1 -1
- package/lib/typescript/components/MainComponents/ProfileImagePlaceholder.d.ts.map +1 -1
- package/lib/typescript/components/MainComponents/RoomList.d.ts.map +1 -1
- package/lib/typescript/components/Menu/HeaderRoomListMenu.d.ts +0 -3
- package/lib/typescript/components/Menu/HeaderRoomListMenu.d.ts.map +1 -1
- package/lib/typescript/components/Modals/AttachSheet/AttachSheet.d.ts +0 -9
- package/lib/typescript/components/Modals/AttachSheet/AttachSheet.d.ts.map +1 -1
- package/lib/typescript/components/Modals/ChatProfileModal/ChatProfileModal.d.ts +0 -10
- package/lib/typescript/components/Modals/ChatProfileModal/ChatProfileModal.d.ts.map +1 -1
- package/lib/typescript/components/Modals/FilePreviewModal/FilePreviewModal.d.ts.map +1 -1
- package/lib/typescript/components/Modals/Modal/Modal.d.ts.map +1 -1
- package/lib/typescript/components/Modals/NewChatModal/ModalContent.d.ts +2 -4
- package/lib/typescript/components/Modals/NewChatModal/ModalContent.d.ts.map +1 -1
- package/lib/typescript/components/Modals/NewChatModal/NewChatModal.d.ts +1 -1
- package/lib/typescript/components/Modals/NewChatModal/NewChatModal.d.ts.map +1 -1
- package/lib/typescript/components/Modals/NewChatModal/UpdNewChatModal.d.ts.map +1 -1
- package/lib/typescript/components/Modals/SelectUsersModal/SelectUsersModal.d.ts +1 -6
- package/lib/typescript/components/Modals/SelectUsersModal/SelectUsersModal.d.ts.map +1 -1
- package/lib/typescript/components/Modals/UserProfileModal/EditUserModal.d.ts.map +1 -1
- package/lib/typescript/components/Modals/UserProfileModal/UserProfileModal.d.ts +0 -16
- package/lib/typescript/components/Modals/UserProfileModal/UserProfileModal.d.ts.map +1 -1
- package/lib/typescript/components/Modals/UserSettingsModal/UserSettingsModal.d.ts +0 -1
- package/lib/typescript/components/Modals/UserSettingsModal/UserSettingsModal.d.ts.map +1 -1
- package/lib/typescript/components/Modals/styledModalComponents.d.ts.map +1 -1
- package/lib/typescript/components/RoomComponents/ChatRoomItem.d.ts.map +1 -1
- package/lib/typescript/components/styled/SendInput.d.ts.map +1 -1
- package/lib/typescript/components/styled/StyledComponents.d.ts.map +1 -1
- package/lib/typescript/components/styled/StyledInputComponents/StyledInputComponents.d.ts.map +1 -1
- package/lib/typescript/context/xmppProvider.d.ts.map +1 -1
- package/lib/typescript/helpers/updateMessagesTillLast.d.ts.map +1 -1
- package/lib/typescript/hooks/useChatRoomFocus.d.ts.map +1 -1
- package/lib/typescript/hooks/useLogout.d.ts.map +1 -1
- package/lib/typescript/hooks/useSendMessage.d.ts.map +1 -1
- package/lib/typescript/i18n/strings.d.ts.map +1 -1
- package/lib/typescript/main.d.ts +1 -1
- package/lib/typescript/main.d.ts.map +1 -1
- package/lib/typescript/networking/api-requests/user.api.d.ts +0 -27
- package/lib/typescript/networking/api-requests/user.api.d.ts.map +1 -1
- package/lib/typescript/networking/outboundQueue.d.ts +16 -0
- package/lib/typescript/networking/outboundQueue.d.ts.map +1 -1
- package/lib/typescript/networking/stanzaHandlers.d.ts.map +1 -1
- package/lib/typescript/networking/xmppClient.d.ts +33 -1
- package/lib/typescript/networking/xmppClient.d.ts.map +1 -1
- package/lib/typescript/roomStore/chatSettingsSlice.d.ts.map +1 -1
- package/lib/typescript/roomStore/roomsSlice.d.ts +18 -1
- package/lib/typescript/roomStore/roomsSlice.d.ts.map +1 -1
- package/lib/typescript/types/models/room.model.d.ts +15 -0
- package/lib/typescript/types/models/room.model.d.ts.map +1 -1
- package/lib/typescript/types/types.d.ts +20 -20
- package/lib/typescript/types/types.d.ts.map +1 -1
- package/package.json +1 -6
- package/src/assets/icons.tsx +9 -48
- package/src/components/Header/HeaderRoomList.tsx +5 -20
- package/src/components/MainComponents/ChatRoom.tsx +20 -38
- package/src/components/MainComponents/MessageList.tsx +24 -8
- package/src/components/MainComponents/ProfileImagePlaceholder.tsx +14 -21
- package/src/components/MainComponents/RoomList.tsx +34 -65
- package/src/components/Menu/HeaderRoomListMenu.tsx +71 -310
- package/src/components/Modals/AttachSheet/AttachSheet.tsx +97 -331
- package/src/components/Modals/ChatProfileModal/ChatProfileModal.tsx +279 -598
- package/src/components/Modals/FilePreviewModal/FilePreviewModal.tsx +2 -4
- package/src/components/Modals/Modal/Modal.tsx +0 -7
- package/src/components/Modals/NewChatModal/ModalContent.tsx +3 -6
- package/src/components/Modals/NewChatModal/NewChatModal.tsx +117 -219
- package/src/components/Modals/NewChatModal/UpdNewChatModal.tsx +1 -12
- package/src/components/Modals/SelectUsersModal/SelectUsersModal.tsx +4 -14
- package/src/components/Modals/UserProfileModal/EditUserModal.tsx +25 -9
- package/src/components/Modals/UserProfileModal/UserProfileModal.tsx +307 -617
- package/src/components/Modals/UserSettingsModal/UserSettingsModal.tsx +58 -75
- package/src/components/Modals/styledModalComponents.tsx +2 -9
- package/src/components/RoomComponents/ChatRoomItem.tsx +7 -14
- package/src/components/styled/SendInput.tsx +12 -83
- package/src/components/styled/StyledComponents.ts +3 -9
- package/src/components/styled/StyledInputComponents/StyledInputComponents.tsx +4 -11
- package/src/context/xmppProvider.tsx +41 -8
- package/src/helpers/updateMessagesTillLast.tsx +42 -17
- package/src/hooks/useChatRoomFocus.ts +11 -3
- package/src/hooks/useLogout.tsx +7 -0
- package/src/hooks/useSendMessage.tsx +60 -24
- package/src/i18n/strings.ts +1 -121
- package/src/main.ts +1 -1
- package/src/networking/api-requests/user.api.ts +0 -71
- package/src/networking/outboundQueue.ts +29 -0
- package/src/networking/stanzaHandlers.ts +9 -1
- package/src/networking/xmppClient.ts +118 -7
- package/src/roomStore/chatSettingsSlice.ts +1 -3
- package/src/roomStore/roomsSlice.ts +20 -2
- package/src/types/models/room.model.ts +15 -0
- package/src/types/types.ts +20 -22
- package/lib/commonjs/components/Modals/ChatProfileModal/ReportChatModal.js +0 -226
- package/lib/commonjs/components/Modals/ChatProfileModal/ReportChatModal.js.map +0 -1
- package/lib/commonjs/components/Modals/ProfileHeader/ProfileHeader.js +0 -556
- package/lib/commonjs/components/Modals/ProfileHeader/ProfileHeader.js.map +0 -1
- package/lib/commonjs/components/Modals/ProfileHeader/ProfileMenu.js +0 -210
- package/lib/commonjs/components/Modals/ProfileHeader/ProfileMenu.js.map +0 -1
- package/lib/commonjs/helpers/getChatBackground.js +0 -23
- package/lib/commonjs/helpers/getChatBackground.js.map +0 -1
- package/lib/commonjs/helpers/mediaLibraryRuntime.js +0 -31
- package/lib/commonjs/helpers/mediaLibraryRuntime.js.map +0 -1
- package/lib/commonjs/helpers/pickImageAsset.js +0 -68
- package/lib/commonjs/helpers/pickImageAsset.js.map +0 -1
- package/lib/commonjs/helpers/sheetGestures.js +0 -32
- package/lib/commonjs/helpers/sheetGestures.js.map +0 -1
- package/lib/module/components/Modals/ChatProfileModal/ReportChatModal.js +0 -223
- package/lib/module/components/Modals/ChatProfileModal/ReportChatModal.js.map +0 -1
- package/lib/module/components/Modals/ProfileHeader/ProfileHeader.js +0 -548
- package/lib/module/components/Modals/ProfileHeader/ProfileHeader.js.map +0 -1
- package/lib/module/components/Modals/ProfileHeader/ProfileMenu.js +0 -205
- package/lib/module/components/Modals/ProfileHeader/ProfileMenu.js.map +0 -1
- package/lib/module/helpers/getChatBackground.js +0 -18
- package/lib/module/helpers/getChatBackground.js.map +0 -1
- package/lib/module/helpers/mediaLibraryRuntime.js +0 -25
- package/lib/module/helpers/mediaLibraryRuntime.js.map +0 -1
- package/lib/module/helpers/pickImageAsset.js +0 -63
- package/lib/module/helpers/pickImageAsset.js.map +0 -1
- package/lib/module/helpers/sheetGestures.js +0 -26
- package/lib/module/helpers/sheetGestures.js.map +0 -1
- package/lib/typescript/components/Modals/ChatProfileModal/ReportChatModal.d.ts +0 -9
- package/lib/typescript/components/Modals/ChatProfileModal/ReportChatModal.d.ts.map +0 -1
- package/lib/typescript/components/Modals/ProfileHeader/ProfileHeader.d.ts +0 -75
- package/lib/typescript/components/Modals/ProfileHeader/ProfileHeader.d.ts.map +0 -1
- package/lib/typescript/components/Modals/ProfileHeader/ProfileMenu.d.ts +0 -25
- package/lib/typescript/components/Modals/ProfileHeader/ProfileMenu.d.ts.map +0 -1
- package/lib/typescript/helpers/getChatBackground.d.ts +0 -15
- package/lib/typescript/helpers/getChatBackground.d.ts.map +0 -1
- package/lib/typescript/helpers/mediaLibraryRuntime.d.ts +0 -3
- package/lib/typescript/helpers/mediaLibraryRuntime.d.ts.map +0 -1
- package/lib/typescript/helpers/pickImageAsset.d.ts +0 -27
- package/lib/typescript/helpers/pickImageAsset.d.ts.map +0 -1
- package/lib/typescript/helpers/sheetGestures.d.ts +0 -20
- package/lib/typescript/helpers/sheetGestures.d.ts.map +0 -1
- package/src/components/Modals/ChatProfileModal/ReportChatModal.tsx +0 -244
- package/src/components/Modals/ProfileHeader/ProfileHeader.tsx +0 -615
- package/src/components/Modals/ProfileHeader/ProfileMenu.tsx +0 -217
- package/src/helpers/getChatBackground.ts +0 -18
- package/src/helpers/mediaLibraryRuntime.ts +0 -25
- package/src/helpers/pickImageAsset.ts +0 -68
- package/src/helpers/sheetGestures.ts +0 -25
|
@@ -26,7 +26,7 @@ import {
|
|
|
26
26
|
import { useVideoPlayer, VideoView } from 'expo-video';
|
|
27
27
|
import { PlayIcon } from '../../../assets/icons';
|
|
28
28
|
import * as FileSystem from 'expo-file-system/legacy';
|
|
29
|
-
import
|
|
29
|
+
import * as MediaLibrary from 'expo-media-library';
|
|
30
30
|
import { useToast } from '../../../context/ToastContext';
|
|
31
31
|
import PdfViewer from './PdfView';
|
|
32
32
|
import DocumentViewer from './DocumentViewer';
|
|
@@ -129,8 +129,6 @@ const FilePreviewModal: React.FC<FilePreviewModalProps> = ({
|
|
|
129
129
|
if (!activeFile) {return null;}
|
|
130
130
|
|
|
131
131
|
const requestStoragePermission = async () => {
|
|
132
|
-
const MediaLibrary = getMediaLibrary();
|
|
133
|
-
if (!MediaLibrary?.requestPermissionsAsync) {return false;}
|
|
134
132
|
try {
|
|
135
133
|
const { status } = await MediaLibrary.requestPermissionsAsync();
|
|
136
134
|
return status === 'granted';
|
|
@@ -160,7 +158,7 @@ const FilePreviewModal: React.FC<FilePreviewModalProps> = ({
|
|
|
160
158
|
const download = await FileSystem.downloadAsync(withFileToken(activeFile.fileURL), filePath);
|
|
161
159
|
|
|
162
160
|
if (download.status === 200) {
|
|
163
|
-
await
|
|
161
|
+
await MediaLibrary.saveToLibraryAsync(download.uri);
|
|
164
162
|
showToast({
|
|
165
163
|
id: Date.now().toString(),
|
|
166
164
|
title: 'Success',
|
|
@@ -37,13 +37,6 @@ const Modal: React.FC<ModalProps> = ({ children, modal, setOpenModal }) => {
|
|
|
37
37
|
|
|
38
38
|
return <ModalComponent handleCloseModal={handleClose} />;
|
|
39
39
|
};
|
|
40
|
-
// Modals that present themselves (a real RN <Modal>, so the dim covers
|
|
41
|
-
// the whole window rather than stopping at this component's frame) must
|
|
42
|
-
// not also sit inside the shared in-tree backdrop — that would dim twice.
|
|
43
|
-
if (modal === MODAL_TYPES.NEW_CHAT) {
|
|
44
|
-
return <>{renderModalContent()}{children}</>;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
40
|
return (
|
|
48
41
|
modal && (
|
|
49
42
|
<ModalBackground
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { PickedImage } from '../../../helpers/pickImageAsset';
|
|
3
2
|
import {
|
|
4
3
|
ModalContainer,
|
|
5
4
|
CloseButton,
|
|
@@ -20,13 +19,12 @@ type ModalContentProps = {
|
|
|
20
19
|
roomName: string;
|
|
21
20
|
roomDescription: string;
|
|
22
21
|
chatType: ChatAccessOption;
|
|
23
|
-
profileImage: string |
|
|
22
|
+
profileImage: string | File | null;
|
|
24
23
|
setActiveTab: (tab: '0' | '1' | null) => void;
|
|
25
24
|
handleRoomNameChange: (e: string) => void;
|
|
26
25
|
setRoomDescription: (description: string) => void;
|
|
27
26
|
setChatType: (type: ChatAccessOption) => void;
|
|
28
|
-
setProfileImage: (image: string |
|
|
29
|
-
onUploadImage: () => void;
|
|
27
|
+
setProfileImage: (image: string | File | null) => void;
|
|
30
28
|
selectedUsers: any[];
|
|
31
29
|
setSelectedUsers: (users: any[]) => void;
|
|
32
30
|
handleCreateRoom: () => void;
|
|
@@ -42,7 +40,6 @@ const ModalContent: React.FC<ModalContentProps> = ({
|
|
|
42
40
|
roomDescription,
|
|
43
41
|
chatType,
|
|
44
42
|
profileImage,
|
|
45
|
-
onUploadImage,
|
|
46
43
|
setActiveTab,
|
|
47
44
|
handleRoomNameChange,
|
|
48
45
|
setChatType,
|
|
@@ -65,7 +62,7 @@ const ModalContent: React.FC<ModalContentProps> = ({
|
|
|
65
62
|
<ModalTitle>Create New Chat</ModalTitle>
|
|
66
63
|
<ProfileImagePlaceholder
|
|
67
64
|
size={120}
|
|
68
|
-
upload={{ active: true, onUpload:
|
|
65
|
+
upload={{ active: true, onUpload: setProfileImage }}
|
|
69
66
|
remove={{
|
|
70
67
|
enabled: true,
|
|
71
68
|
onRemoveClick: () => setProfileImage(null),
|
|
@@ -1,24 +1,20 @@
|
|
|
1
|
-
import React, { useState, useMemo } from 'react';
|
|
2
|
-
import
|
|
1
|
+
import React, { useState, useEffect, useMemo } from 'react';
|
|
2
|
+
import Button from '../../styled/Button';
|
|
3
|
+
import { AddNewIcon, AddPhotoIcon } from '../../../assets/icons';
|
|
3
4
|
import { RootState } from '../../../roomStore';
|
|
4
5
|
import { useXmppClient } from '../../../context/xmppProvider';
|
|
6
|
+
import {
|
|
7
|
+
CloseButton,
|
|
8
|
+
GroupContainer,
|
|
9
|
+
ModalBackground,
|
|
10
|
+
ModalContainer,
|
|
11
|
+
ModalTitle,
|
|
12
|
+
} from '../styledModalComponents';
|
|
5
13
|
import { addRoomViaApi, setCurrentRoom, updateRoom } from '../../../roomStore/roomsSlice';
|
|
14
|
+
import InputWithLabel from '../../styled/StyledInput';
|
|
6
15
|
import { uploadFile } from '../../../networking/api-requests/auth.api';
|
|
7
|
-
import {
|
|
8
|
-
|
|
9
|
-
Alert,
|
|
10
|
-
Image,
|
|
11
|
-
Linking,
|
|
12
|
-
Modal,
|
|
13
|
-
Pressable,
|
|
14
|
-
StyleSheet,
|
|
15
|
-
Text,
|
|
16
|
-
TextInput,
|
|
17
|
-
TouchableOpacity,
|
|
18
|
-
View,
|
|
19
|
-
} from 'react-native';
|
|
20
|
-
import { getIconColor } from '../../../helpers/getIconColor';
|
|
21
|
-
import { useT } from '../../../i18n/useT';
|
|
16
|
+
import { ProfileImagePlaceholder } from '../../MainComponents/ProfileImagePlaceholder';
|
|
17
|
+
import { Text, Alert, Linking } from 'react-native';
|
|
22
18
|
import * as ImagePicker from 'expo-image-picker';
|
|
23
19
|
import { ApiRoom, ChatAccessOption, RoomMember } from '../../../types/models/room.model';
|
|
24
20
|
import { createRoomFromApi } from '../../../helpers/createRoomFromApi';
|
|
@@ -28,16 +24,16 @@ import { useChatSettingState } from '../../../hooks/useChatSettingState';
|
|
|
28
24
|
import { useToast } from '../../../context/ToastContext';
|
|
29
25
|
|
|
30
26
|
interface NewChatModalProps {
|
|
31
|
-
handleCloseModal?:
|
|
27
|
+
handleCloseModal?: any;
|
|
32
28
|
}
|
|
33
29
|
|
|
34
30
|
const NewChatModal: React.FC<NewChatModalProps> = ({
|
|
35
31
|
// Some call sites mount `<NewChatModal />` with no props (e.g. the
|
|
36
|
-
// empty-state in ChatRoom when roomsList is empty).
|
|
37
|
-
//
|
|
38
|
-
|
|
32
|
+
// empty-state in ChatRoom when roomsList is empty). Default to a noop
|
|
33
|
+
// so the Close/Cancel buttons don't throw "handleClose is not a
|
|
34
|
+
// function".
|
|
35
|
+
handleCloseModal: handleClose = () => {},
|
|
39
36
|
}) => {
|
|
40
|
-
const t = useT();
|
|
41
37
|
const config = useAppSelector(
|
|
42
38
|
(state: RootState) => state.chatSettingStore.config
|
|
43
39
|
);
|
|
@@ -47,7 +43,9 @@ const NewChatModal: React.FC<NewChatModalProps> = ({
|
|
|
47
43
|
const { user } = useChatSettingState();
|
|
48
44
|
const { showToast } = useToast();
|
|
49
45
|
|
|
46
|
+
const [isModalOpen, setIsModalOpen] = useState<boolean>(false);
|
|
50
47
|
const [loading, setLoading] = useState<boolean>(false);
|
|
48
|
+
const [activeTab, setActiveTab] = useState<'0' | '1' | null>('0');
|
|
51
49
|
|
|
52
50
|
const [roomName, setRoomName] = useState<string>('');
|
|
53
51
|
const [roomDescription, setRoomDescription] = useState<string>('');
|
|
@@ -67,7 +65,7 @@ const NewChatModal: React.FC<NewChatModalProps> = ({
|
|
|
67
65
|
|
|
68
66
|
const validateRoomName = (name: string) => {
|
|
69
67
|
if (name.trim().length < 3) {
|
|
70
|
-
return
|
|
68
|
+
return 'Room name must be at least 3 characters.';
|
|
71
69
|
}
|
|
72
70
|
return '';
|
|
73
71
|
};
|
|
@@ -99,17 +97,13 @@ const NewChatModal: React.FC<NewChatModalProps> = ({
|
|
|
99
97
|
}));
|
|
100
98
|
};
|
|
101
99
|
|
|
102
|
-
const
|
|
100
|
+
const handleOpenModal = () => setIsModalOpen(true);
|
|
101
|
+
const handleCloseModal = () => {
|
|
102
|
+
handleClose();
|
|
103
|
+
setActiveTab('0');
|
|
104
|
+
setIsModalOpen(false);
|
|
103
105
|
setRoomName('');
|
|
104
|
-
setRoomDescription('');
|
|
105
|
-
setProfileImage(null);
|
|
106
106
|
setSelectedUsers([]);
|
|
107
|
-
setErrors({ name: '', description: '' });
|
|
108
|
-
};
|
|
109
|
-
|
|
110
|
-
const handleCloseModal = () => {
|
|
111
|
-
resetForm();
|
|
112
|
-
handleClose?.();
|
|
113
107
|
};
|
|
114
108
|
|
|
115
109
|
const onUpload = async () => {
|
|
@@ -135,7 +129,7 @@ const NewChatModal: React.FC<NewChatModalProps> = ({
|
|
|
135
129
|
quality: 0.8,
|
|
136
130
|
});
|
|
137
131
|
|
|
138
|
-
if (result.canceled)
|
|
132
|
+
if (result.canceled) return;
|
|
139
133
|
|
|
140
134
|
const asset = result.assets[0];
|
|
141
135
|
const originalName = asset.uri.split('/').pop();
|
|
@@ -167,7 +161,7 @@ const NewChatModal: React.FC<NewChatModalProps> = ({
|
|
|
167
161
|
usersArrayLength
|
|
168
162
|
);
|
|
169
163
|
|
|
170
|
-
if (!normalizedChat || !client)
|
|
164
|
+
if (!normalizedChat || !client) return;
|
|
171
165
|
|
|
172
166
|
dispatch(
|
|
173
167
|
addRoomViaApi({
|
|
@@ -267,199 +261,103 @@ const NewChatModal: React.FC<NewChatModalProps> = ({
|
|
|
267
261
|
}
|
|
268
262
|
}
|
|
269
263
|
|
|
270
|
-
|
|
264
|
+
setIsModalOpen(false);
|
|
265
|
+
setErrors({ name: '', description: '' });
|
|
266
|
+
setProfileImage(null);
|
|
267
|
+
setRoomName('');
|
|
268
|
+
setRoomDescription('');
|
|
271
269
|
setLoading(false);
|
|
272
270
|
}
|
|
273
271
|
};
|
|
274
272
|
|
|
275
|
-
const primary = getIconColor(config);
|
|
276
|
-
const pickedUri =
|
|
277
|
-
profileImage && typeof profileImage === 'object' && 'uri' in profileImage
|
|
278
|
-
? profileImage.uri
|
|
279
|
-
: typeof profileImage === 'string'
|
|
280
|
-
? profileImage
|
|
281
|
-
: null;
|
|
282
|
-
|
|
283
273
|
return (
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
<
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
{
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
style={styles.input}
|
|
321
|
-
value={roomName}
|
|
322
|
-
onChangeText={handleRoomNameChange}
|
|
323
|
-
placeholder={t('modal.newChat.roomNamePlaceholder')}
|
|
324
|
-
placeholderTextColor="#8C8C8C"
|
|
325
|
-
returnKeyType="next"
|
|
326
|
-
/>
|
|
327
|
-
{!!errors.name && roomName.length > 0 && (
|
|
328
|
-
<Text testID="new-chat-name-error" style={styles.error}>
|
|
329
|
-
{errors.name}
|
|
330
|
-
</Text>
|
|
331
|
-
)}
|
|
332
|
-
|
|
333
|
-
<TextInput
|
|
334
|
-
testID="new-chat-description"
|
|
335
|
-
style={[styles.input, styles.textArea]}
|
|
336
|
-
value={roomDescription}
|
|
337
|
-
onChangeText={handleRoomDescriptionChange}
|
|
338
|
-
placeholder={t('modal.newChat.descriptionPlaceholder')}
|
|
339
|
-
placeholderTextColor="#8C8C8C"
|
|
340
|
-
multiline
|
|
274
|
+
<>
|
|
275
|
+
{/* <Button
|
|
276
|
+
style={{
|
|
277
|
+
padding: 8,
|
|
278
|
+
borderRadius: 16,
|
|
279
|
+
backgroundColor: "transparent",
|
|
280
|
+
}}
|
|
281
|
+
color="black"
|
|
282
|
+
unstyled
|
|
283
|
+
EndIcon={<AddNewIcon color={config?.colors?.primary} />}
|
|
284
|
+
onPress={handleOpenModal}
|
|
285
|
+
/> */}
|
|
286
|
+
|
|
287
|
+
<ModalBackground
|
|
288
|
+
// visible={isModalOpen}
|
|
289
|
+
// transparent={true}
|
|
290
|
+
// animationType="fade"
|
|
291
|
+
// onRequestClose={handleCloseModal}
|
|
292
|
+
>
|
|
293
|
+
<ModalContainer>
|
|
294
|
+
<CloseButton onPress={handleCloseModal}>
|
|
295
|
+
<Text style={{ fontSize: 24, padding: 5 }}>×</Text>
|
|
296
|
+
</CloseButton>
|
|
297
|
+
<ModalTitle>Create New Chat</ModalTitle>
|
|
298
|
+
<ProfileImagePlaceholder
|
|
299
|
+
size={120}
|
|
300
|
+
upload={{ active: true, onUpload }}
|
|
301
|
+
remove={{ enabled: true, onRemoveClick }}
|
|
302
|
+
placeholderIcon={<AddPhotoIcon color="#0052CD" />}
|
|
303
|
+
icon={
|
|
304
|
+
profileImage && typeof profileImage === 'object' && 'uri' in profileImage
|
|
305
|
+
? { uri: profileImage.uri }
|
|
306
|
+
: profileImage
|
|
307
|
+
}
|
|
308
|
+
disableOverlay={!profileImage}
|
|
309
|
+
role="user"
|
|
341
310
|
/>
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
311
|
+
<GroupContainer
|
|
312
|
+
style={{
|
|
313
|
+
flexDirection: 'column',
|
|
314
|
+
position: 'relative',
|
|
315
|
+
width: '100%',
|
|
316
|
+
}}
|
|
317
|
+
>
|
|
318
|
+
<InputWithLabel
|
|
319
|
+
color="#F5F7F9"
|
|
320
|
+
id="roomName"
|
|
321
|
+
value={roomName}
|
|
322
|
+
onChangeText={handleRoomNameChange}
|
|
323
|
+
placeholder="Enter Room Name"
|
|
324
|
+
helperText={errors.name}
|
|
325
|
+
error={!!errors.name}
|
|
326
|
+
/>
|
|
327
|
+
<InputWithLabel
|
|
328
|
+
color="#F5F7F9"
|
|
329
|
+
id="roomDescription"
|
|
330
|
+
value={roomDescription}
|
|
331
|
+
onChangeText={handleRoomDescriptionChange}
|
|
332
|
+
placeholder="Enter Description"
|
|
333
|
+
helperText={errors.description}
|
|
334
|
+
error={!!errors.description}
|
|
335
|
+
/>
|
|
336
|
+
</GroupContainer>
|
|
337
|
+
|
|
338
|
+
<GroupContainer>
|
|
339
|
+
<Button
|
|
360
340
|
onPress={handleCreateRoom}
|
|
361
|
-
|
|
362
|
-
{
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
341
|
+
text={'Create'}
|
|
342
|
+
style={{ width: '100%' }}
|
|
343
|
+
unstyled
|
|
344
|
+
variant="filled"
|
|
345
|
+
disabled={!isValid}
|
|
346
|
+
color="#fff"
|
|
347
|
+
/>
|
|
348
|
+
<Button
|
|
349
|
+
onPress={handleCloseModal}
|
|
350
|
+
text={'Cancel'}
|
|
351
|
+
style={{ width: '100%' }}
|
|
352
|
+
unstyled
|
|
353
|
+
variant="outlined"
|
|
354
|
+
color="#0052CD"
|
|
355
|
+
/>
|
|
356
|
+
</GroupContainer>
|
|
357
|
+
</ModalContainer>
|
|
358
|
+
</ModalBackground>
|
|
359
|
+
</>
|
|
374
360
|
);
|
|
375
361
|
};
|
|
376
362
|
|
|
377
|
-
const styles = StyleSheet.create({
|
|
378
|
-
backdrop: {
|
|
379
|
-
flex: 1,
|
|
380
|
-
// Opaque, per the design: the chat list behind stays hidden rather
|
|
381
|
-
// than showing through a translucent dim.
|
|
382
|
-
backgroundColor: '#E9EDF2',
|
|
383
|
-
alignItems: 'center',
|
|
384
|
-
justifyContent: 'center',
|
|
385
|
-
padding: 24,
|
|
386
|
-
},
|
|
387
|
-
card: {
|
|
388
|
-
width: '100%',
|
|
389
|
-
maxWidth: 380,
|
|
390
|
-
borderRadius: 20,
|
|
391
|
-
backgroundColor: '#FFFFFF',
|
|
392
|
-
padding: 20,
|
|
393
|
-
shadowColor: '#121219',
|
|
394
|
-
shadowOffset: { width: 0, height: 8 },
|
|
395
|
-
shadowOpacity: 0.08,
|
|
396
|
-
shadowRadius: 24,
|
|
397
|
-
elevation: 6,
|
|
398
|
-
},
|
|
399
|
-
title: {
|
|
400
|
-
fontSize: 17,
|
|
401
|
-
fontWeight: '700',
|
|
402
|
-
color: '#141414',
|
|
403
|
-
textAlign: 'center',
|
|
404
|
-
},
|
|
405
|
-
picture: {
|
|
406
|
-
alignSelf: 'center',
|
|
407
|
-
width: 72,
|
|
408
|
-
height: 72,
|
|
409
|
-
borderRadius: 36,
|
|
410
|
-
marginVertical: 18,
|
|
411
|
-
alignItems: 'center',
|
|
412
|
-
justifyContent: 'center',
|
|
413
|
-
overflow: 'hidden',
|
|
414
|
-
},
|
|
415
|
-
pictureImage: {
|
|
416
|
-
width: '100%',
|
|
417
|
-
height: '100%',
|
|
418
|
-
},
|
|
419
|
-
input: {
|
|
420
|
-
borderRadius: 12,
|
|
421
|
-
backgroundColor: '#F4F5F7',
|
|
422
|
-
paddingHorizontal: 14,
|
|
423
|
-
paddingVertical: 12,
|
|
424
|
-
fontSize: 15,
|
|
425
|
-
color: '#141414',
|
|
426
|
-
marginTop: 10,
|
|
427
|
-
},
|
|
428
|
-
textArea: {
|
|
429
|
-
minHeight: 84,
|
|
430
|
-
textAlignVertical: 'top',
|
|
431
|
-
},
|
|
432
|
-
error: {
|
|
433
|
-
color: '#E53935',
|
|
434
|
-
fontSize: 12,
|
|
435
|
-
marginTop: 6,
|
|
436
|
-
marginLeft: 4,
|
|
437
|
-
},
|
|
438
|
-
buttons: {
|
|
439
|
-
flexDirection: 'row',
|
|
440
|
-
gap: 12,
|
|
441
|
-
marginTop: 20,
|
|
442
|
-
},
|
|
443
|
-
button: {
|
|
444
|
-
flex: 1,
|
|
445
|
-
height: 44,
|
|
446
|
-
borderRadius: 12,
|
|
447
|
-
alignItems: 'center',
|
|
448
|
-
justifyContent: 'center',
|
|
449
|
-
},
|
|
450
|
-
cancel: {
|
|
451
|
-
backgroundColor: '#E7E8EA',
|
|
452
|
-
},
|
|
453
|
-
cancelLabel: {
|
|
454
|
-
fontSize: 15,
|
|
455
|
-
fontWeight: '500',
|
|
456
|
-
color: '#8C8C8C',
|
|
457
|
-
},
|
|
458
|
-
submitLabel: {
|
|
459
|
-
fontSize: 15,
|
|
460
|
-
fontWeight: '600',
|
|
461
|
-
color: '#FFFFFF',
|
|
462
|
-
},
|
|
463
|
-
});
|
|
464
|
-
|
|
465
363
|
export default NewChatModal;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import React, { useState, useMemo } from 'react';
|
|
2
|
-
import { pickImageAsset, PickedImage } from '../../../helpers/pickImageAsset';
|
|
3
2
|
import Button from '../../styled/Button';
|
|
4
3
|
import { AddNewIcon } from '../../../assets/icons';
|
|
5
4
|
import { useDispatch, useSelector } from 'react-redux';
|
|
@@ -30,16 +29,7 @@ const NewChatModal: React.FC = () => {
|
|
|
30
29
|
name: 'Public',
|
|
31
30
|
id: 'public',
|
|
32
31
|
});
|
|
33
|
-
const [profileImage, setProfileImage] = useState<
|
|
34
|
-
string | PickedImage | null
|
|
35
|
-
>(null);
|
|
36
|
-
|
|
37
|
-
const handleUploadImage = async () => {
|
|
38
|
-
const picked = await pickImageAsset();
|
|
39
|
-
if (picked) {
|
|
40
|
-
setProfileImage(picked);
|
|
41
|
-
}
|
|
42
|
-
};
|
|
32
|
+
const [profileImage, setProfileImage] = useState<string | File | null>(null);
|
|
43
33
|
const [errors, setErrors] = useState({ name: '', description: '' });
|
|
44
34
|
const [selectedUsers, setSelectedUsers] = useState<RoomMember[]>([]);
|
|
45
35
|
|
|
@@ -129,7 +119,6 @@ const NewChatModal: React.FC = () => {
|
|
|
129
119
|
setRoomDescription={setRoomDescription}
|
|
130
120
|
setChatType={setChatType}
|
|
131
121
|
setProfileImage={setProfileImage}
|
|
132
|
-
onUploadImage={handleUploadImage}
|
|
133
122
|
selectedUsers={selectedUsers}
|
|
134
123
|
setSelectedUsers={setSelectedUsers}
|
|
135
124
|
handleCreateRoom={handleCreateRoom}
|
|
@@ -17,13 +17,7 @@ import { useToast } from '../../../context/ToastContext';
|
|
|
17
17
|
import { updateRoom } from '../../../roomStore/roomsSlice';
|
|
18
18
|
import { Text } from 'react-native';
|
|
19
19
|
|
|
20
|
-
|
|
21
|
-
/** Render the opener yourself (the chat profile uses an "Add Members"
|
|
22
|
-
* row). Falls back to the plain "Add more Users" button. */
|
|
23
|
-
trigger?: (open: () => void) => React.ReactNode;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
const SelectUsersModal: React.FC<SelectUsersModalProps> = ({ trigger }) => {
|
|
20
|
+
const SelectUsersModal: React.FC = () => {
|
|
27
21
|
const { showToast } = useToast();
|
|
28
22
|
const dispatch = useDispatch();
|
|
29
23
|
|
|
@@ -80,13 +74,9 @@ const SelectUsersModal: React.FC<SelectUsersModalProps> = ({ trigger }) => {
|
|
|
80
74
|
|
|
81
75
|
return (
|
|
82
76
|
<>
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
<ActionButton variant="filled" unstyled onPress={handleOpenModal}>
|
|
87
|
-
Add more Users
|
|
88
|
-
</ActionButton>
|
|
89
|
-
)}
|
|
77
|
+
<ActionButton variant="filled" unstyled onPress={handleOpenModal}>
|
|
78
|
+
Add more Users
|
|
79
|
+
</ActionButton>
|
|
90
80
|
|
|
91
81
|
{isModalOpen && (
|
|
92
82
|
<ModalBackground>
|
|
@@ -8,10 +8,23 @@ import { updateProfile } from '../../../networking/api-requests/user.api';
|
|
|
8
8
|
import { useDispatch } from 'react-redux';
|
|
9
9
|
import { updateUser } from '../../../roomStore/chatSettingsSlice';
|
|
10
10
|
import { View } from 'react-native';
|
|
11
|
-
import { pickImageAsset, PickedImage } from '../../../helpers/pickImageAsset';
|
|
12
11
|
import { AddPhotoIcon } from '../../../assets/icons';
|
|
13
12
|
// import { actionUpdateUser } from '../actions';
|
|
14
13
|
|
|
14
|
+
const base64ToFile = (base64String: string, fileName: string) => {
|
|
15
|
+
const byteString = atob(base64String.split(',')[1]);
|
|
16
|
+
const arrayBuffer = new ArrayBuffer(byteString.length);
|
|
17
|
+
const uintArray = new Uint8Array(arrayBuffer);
|
|
18
|
+
for (let i = 0; i < byteString.length; i++) {
|
|
19
|
+
uintArray[i] = byteString.charCodeAt(i);
|
|
20
|
+
}
|
|
21
|
+
const blob = new Blob([uintArray], { type: 'image/jpeg' });
|
|
22
|
+
return new File([blob], fileName, {
|
|
23
|
+
type: 'image/jpeg',
|
|
24
|
+
lastModified: Date.now(),
|
|
25
|
+
});
|
|
26
|
+
};
|
|
27
|
+
|
|
15
28
|
interface EditUserModalProps {
|
|
16
29
|
setIsEditing: React.Dispatch<React.SetStateAction<boolean>>;
|
|
17
30
|
modalUser: any;
|
|
@@ -28,7 +41,7 @@ const EditUserModal: React.FC<EditUserModalProps> = ({
|
|
|
28
41
|
const [firstName, setFirstName] = useState(modalUser?.firstName || '');
|
|
29
42
|
const [lastName, setLastName] = useState(modalUser?.lastName || '');
|
|
30
43
|
const [description, setDescription] = useState(modalUser?.description || '');
|
|
31
|
-
const [profileImage, setProfileImage] = useState<string |
|
|
44
|
+
const [profileImage, setProfileImage] = useState<string | File>(
|
|
32
45
|
modalUser?.profileImage
|
|
33
46
|
);
|
|
34
47
|
|
|
@@ -36,8 +49,14 @@ const EditUserModal: React.FC<EditUserModalProps> = ({
|
|
|
36
49
|
try {
|
|
37
50
|
let fd = new FormData();
|
|
38
51
|
|
|
39
|
-
if (
|
|
40
|
-
|
|
52
|
+
if (
|
|
53
|
+
typeof profileImage === 'string' &&
|
|
54
|
+
profileImage.startsWith('data:image/')
|
|
55
|
+
) {
|
|
56
|
+
const file = base64ToFile(profileImage, 'profileImage.jpg');
|
|
57
|
+
fd.append('file', file);
|
|
58
|
+
} else if (profileImage instanceof File) {
|
|
59
|
+
fd.append('file', profileImage);
|
|
41
60
|
}
|
|
42
61
|
|
|
43
62
|
fd.append('firstName', firstName);
|
|
@@ -63,11 +82,8 @@ const EditUserModal: React.FC<EditUserModalProps> = ({
|
|
|
63
82
|
}
|
|
64
83
|
};
|
|
65
84
|
|
|
66
|
-
const handleProfileImageChange =
|
|
67
|
-
|
|
68
|
-
if (picked) {
|
|
69
|
-
setProfileImage(picked);
|
|
70
|
-
}
|
|
85
|
+
const handleProfileImageChange = (image: File) => {
|
|
86
|
+
setProfileImage(image);
|
|
71
87
|
};
|
|
72
88
|
|
|
73
89
|
return (
|