agora-appbuilder-core 4.0.13 → 4.0.15
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/package.json +1 -1
- package/template/_package-lock.json +1364 -1576
- package/template/android/app/src/main/assets/fonts/icomoon.ttf +0 -0
- package/template/customization-api/sub-components.ts +6 -4
- package/template/customization-api/types.ts +0 -6
- package/template/defaultConfig.js +0 -3
- package/template/global.d.ts +0 -3
- package/template/ios/Podfile.lock +0 -10
- package/template/package-lock.json +1364 -1576
- package/template/package.json +0 -4
- package/template/src/SDKAppWrapper.tsx +8 -2
- package/template/src/app-state/useMessages.ts +9 -49
- package/template/src/assets/font-styles.css +125 -289
- package/template/src/assets/fonts/icomoon.ttf +0 -0
- package/template/src/assets/selection.json +1 -1
- package/template/src/atoms/ActionMenu.tsx +2 -5
- package/template/src/atoms/CustomIcon.tsx +1 -17
- package/template/src/atoms/ImageIcon.tsx +3 -19
- package/template/src/atoms/Popup.tsx +4 -13
- package/template/src/atoms/ToolbarPreset.tsx +57 -6
- package/template/src/auth/AuthProvider.tsx +0 -5
- package/template/src/auth/config.ts +3 -12
- package/template/src/components/Chat.tsx +1 -7
- package/template/src/components/ChatContext.ts +0 -12
- package/template/src/components/CommonStyles.ts +2 -2
- package/template/src/components/Controls.tsx +57 -29
- package/template/src/components/Leftbar.tsx +4 -4
- package/template/src/components/Navbar.tsx +54 -29
- package/template/src/components/NavbarMobile.tsx +23 -33
- package/template/src/components/PinnedVideo.tsx +1 -1
- package/template/src/components/RTMConfigure.tsx +0 -1
- package/template/src/components/SdkApiContext.tsx +4 -1
- package/template/src/components/chat-messages/useChatMessages.tsx +607 -411
- package/template/src/components/chat-ui/useChatUIControls.tsx +0 -53
- package/template/src/components/meeting-info-invite/MeetingInfoGridTile.tsx +1 -4
- package/template/src/components/participants/Participant.tsx +1 -0
- package/template/src/components/precall/joinWaitingRoomBtn.native.tsx +1 -6
- package/template/src/components/precall/joinWaitingRoomBtn.tsx +1 -6
- package/template/src/components/room-info/useRoomInfo.tsx +5 -5
- package/template/src/language/default-labels/videoCallScreenLabels.ts +6 -86
- package/template/src/pages/VideoCall.tsx +4 -3
- package/template/src/pages/video-call/ActionSheetContent.tsx +32 -3
- package/template/src/pages/video-call/VideoCallScreenWrapper.tsx +12 -22
- package/template/src/pages/video-call/VideoComponent.tsx +11 -5
- package/template/src/pages/video-call/index.ts +0 -8
- package/template/src/subComponents/ChatBubble.tsx +32 -252
- package/template/src/subComponents/ChatContainer.tsx +4 -14
- package/template/src/subComponents/ChatInput.ios.tsx +184 -0
- package/template/src/subComponents/ChatInput.tsx +100 -276
- package/template/src/subComponents/RemoteMutePopup.tsx +131 -12
- package/template/src/subComponents/caption/CaptionContainer.tsx +2 -6
- package/template/src/subComponents/recording/useRecording.tsx +1 -3
- package/template/src/utils/SdkMethodEvents.ts +1 -0
- package/template/src/utils/common.tsx +17 -0
- package/template/src/utils/index.tsx +0 -30
- package/template/src/utils/useEndCall.ts +0 -7
- package/template/src/utils/useJoinRoom.ts +7 -33
- package/template/android/link-assets-manifest.json +0 -13
- package/template/ios/link-assets-manifest.json +0 -13
- package/template/src/atoms/InlinePopup.tsx +0 -185
- package/template/src/components/chat/chatConfigure.native.tsx +0 -488
- package/template/src/components/chat/chatConfigure.tsx +0 -473
- package/template/src/subComponents/ChatInput.native.tsx +0 -269
- package/template/src/subComponents/chat/ChatActionMenu.tsx +0 -224
- package/template/src/subComponents/chat/ChatAttachment.native.tsx +0 -234
- package/template/src/subComponents/chat/ChatAttachment.tsx +0 -145
- package/template/src/subComponents/chat/ChatEmoji.native.tsx +0 -75
- package/template/src/subComponents/chat/ChatEmoji.tsx +0 -181
- package/template/src/subComponents/chat/ChatSendButton.tsx +0 -141
- package/template/src/subComponents/chat/ChatUploadStatus.tsx +0 -65
- package/template/src/subComponents/chat/ImagePopup.tsx +0 -400
|
@@ -1,488 +0,0 @@
|
|
|
1
|
-
import {createHook} from 'customization-implementation';
|
|
2
|
-
import React, {createContext, useEffect, useState} from 'react';
|
|
3
|
-
import {useRoomInfo} from '../room-info/useRoomInfo';
|
|
4
|
-
import {useContent} from 'customization-api';
|
|
5
|
-
import {
|
|
6
|
-
ChatClient,
|
|
7
|
-
ChatConnectEventListener,
|
|
8
|
-
ChatContactEventListener,
|
|
9
|
-
ChatMessage,
|
|
10
|
-
ChatMessageChatType,
|
|
11
|
-
ChatMessageEventListener,
|
|
12
|
-
ChatOptions,
|
|
13
|
-
ChatMessageStatusCallback,
|
|
14
|
-
} from 'react-native-agora-chat';
|
|
15
|
-
import StorageContext from '../StorageContext';
|
|
16
|
-
import {
|
|
17
|
-
ChatMessageType,
|
|
18
|
-
ChatOption,
|
|
19
|
-
SDKChatType,
|
|
20
|
-
useChatMessages,
|
|
21
|
-
} from '../chat-messages/useChatMessages';
|
|
22
|
-
import {timeNow} from '../../rtm/utils';
|
|
23
|
-
import Share from 'react-native-share';
|
|
24
|
-
import RNFetchBlob from 'rn-fetch-blob';
|
|
25
|
-
import {logger, LogSource} from '../../logger/AppBuilderLogger';
|
|
26
|
-
|
|
27
|
-
interface ChatMessageAttributes {
|
|
28
|
-
file_ext?: string;
|
|
29
|
-
file_name?: string;
|
|
30
|
-
file_url?: string;
|
|
31
|
-
from_platform?: string;
|
|
32
|
-
}
|
|
33
|
-
interface chatConfigureContextInterface {
|
|
34
|
-
open: boolean;
|
|
35
|
-
setOpen: React.Dispatch<React.SetStateAction<boolean>>;
|
|
36
|
-
sendChatSDKMessage: (
|
|
37
|
-
option: ChatOption,
|
|
38
|
-
callback: ChatMessageStatusCallback,
|
|
39
|
-
) => void;
|
|
40
|
-
deleteChatUser: () => void;
|
|
41
|
-
downloadAttachment: (fileName: string, fileUrl: string) => void;
|
|
42
|
-
deleteAttachment: (
|
|
43
|
-
msgId: string,
|
|
44
|
-
privateChatUser: string,
|
|
45
|
-
chatType: string,
|
|
46
|
-
) => void;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
export const chatConfigureContext =
|
|
50
|
-
createContext<chatConfigureContextInterface>({
|
|
51
|
-
open: false,
|
|
52
|
-
setOpen: () => {},
|
|
53
|
-
sendChatSDKMessage: () => {},
|
|
54
|
-
deleteChatUser: () => {},
|
|
55
|
-
downloadAttachment: () => {},
|
|
56
|
-
deleteAttachment: () => {},
|
|
57
|
-
});
|
|
58
|
-
|
|
59
|
-
const ChatConfigure = ({children}) => {
|
|
60
|
-
const [open, setOpen] = useState(false);
|
|
61
|
-
const {data} = useRoomInfo();
|
|
62
|
-
const connRef = React.useRef(null);
|
|
63
|
-
const {defaultContent} = useContent();
|
|
64
|
-
const defaultContentRef = React.useRef(defaultContent);
|
|
65
|
-
const chatClient = ChatClient.getInstance();
|
|
66
|
-
const chatManager = chatClient.chatManager;
|
|
67
|
-
|
|
68
|
-
const localUid = data?.uid?.toString();
|
|
69
|
-
const agoraToken = data?.chat?.user_token;
|
|
70
|
-
const {store} = React.useContext(StorageContext);
|
|
71
|
-
const {
|
|
72
|
-
addMessageToPrivateStore,
|
|
73
|
-
showMessageNotification,
|
|
74
|
-
addMessageToStore,
|
|
75
|
-
removeMessageFromStore,
|
|
76
|
-
removeMessageFromPrivateStore,
|
|
77
|
-
} = useChatMessages();
|
|
78
|
-
|
|
79
|
-
React.useEffect(() => {
|
|
80
|
-
defaultContentRef.current = defaultContent;
|
|
81
|
-
}, [defaultContent]);
|
|
82
|
-
|
|
83
|
-
useEffect(() => {
|
|
84
|
-
const logout = async () => {
|
|
85
|
-
try {
|
|
86
|
-
await chatClient.logout();
|
|
87
|
-
console.warn('logout success');
|
|
88
|
-
logger.log(
|
|
89
|
-
LogSource.Internals,
|
|
90
|
-
'CHAT',
|
|
91
|
-
`Logged out User ${localUid} from Agora Chat Server`,
|
|
92
|
-
);
|
|
93
|
-
} catch (error) {
|
|
94
|
-
console.warn('logout failed');
|
|
95
|
-
logger.log(
|
|
96
|
-
LogSource.Internals,
|
|
97
|
-
'CHAT',
|
|
98
|
-
`Failed Logging out User ${localUid} from Agora Chat Server`,
|
|
99
|
-
);
|
|
100
|
-
}
|
|
101
|
-
};
|
|
102
|
-
const setupMessageListener = () => {
|
|
103
|
-
const msgListerner: ChatMessageEventListener = {
|
|
104
|
-
onMessagesRecalled: (messages: ChatMessage[]) => {
|
|
105
|
-
console.warn('on msg recalled', messages);
|
|
106
|
-
const isGroupChat = messages[0].to === data.chat.group_id;
|
|
107
|
-
if (isGroupChat) {
|
|
108
|
-
removeMessageFromStore(messages[0].msgId.toString(), true);
|
|
109
|
-
} else {
|
|
110
|
-
removeMessageFromPrivateStore(messages[0].msgId.toString(), true);
|
|
111
|
-
}
|
|
112
|
-
},
|
|
113
|
-
onMessagesReceived: (messages: ChatMessage[]) => {
|
|
114
|
-
// all types of msg recivied : text, image, video etc..
|
|
115
|
-
console.warn('on msg rcvd : Native101', messages);
|
|
116
|
-
const isGroupChat =
|
|
117
|
-
messages[0].chatType === ChatMessageChatType.GroupChat;
|
|
118
|
-
const isPeerChat =
|
|
119
|
-
messages[0].chatType === ChatMessageChatType.PeerChat;
|
|
120
|
-
const {msgId, from, body, localTime} = messages[0];
|
|
121
|
-
const chatType = body.type;
|
|
122
|
-
const {file_ext, file_name, file_url, from_platform} = messages[0]
|
|
123
|
-
.attributes as ChatMessageAttributes;
|
|
124
|
-
|
|
125
|
-
//@ts-ignore
|
|
126
|
-
|
|
127
|
-
switch (chatType) {
|
|
128
|
-
case ChatMessageType.TXT:
|
|
129
|
-
//@ts-ignore
|
|
130
|
-
const chatContent = body.content;
|
|
131
|
-
if (isGroupChat) {
|
|
132
|
-
showMessageNotification(chatContent, from, false);
|
|
133
|
-
addMessageToStore(Number(from), {
|
|
134
|
-
msg: chatContent.replace(/^(\n)+|(\n)+$/g, ''),
|
|
135
|
-
createdTimestamp: localTime,
|
|
136
|
-
msgId: msgId,
|
|
137
|
-
isDeleted: false,
|
|
138
|
-
type: ChatMessageType.TXT,
|
|
139
|
-
});
|
|
140
|
-
}
|
|
141
|
-
if (isPeerChat) {
|
|
142
|
-
showMessageNotification(chatContent, from, true);
|
|
143
|
-
addMessageToPrivateStore(
|
|
144
|
-
Number(from),
|
|
145
|
-
{
|
|
146
|
-
msg: chatContent.replace(/^(\n)+|(\n)+$/g, ''),
|
|
147
|
-
createdTimestamp: localTime,
|
|
148
|
-
msgId: msgId,
|
|
149
|
-
isDeleted: false,
|
|
150
|
-
type: ChatMessageType.TXT,
|
|
151
|
-
},
|
|
152
|
-
false,
|
|
153
|
-
);
|
|
154
|
-
}
|
|
155
|
-
break;
|
|
156
|
-
case ChatMessageType.IMAGE:
|
|
157
|
-
const thumb =
|
|
158
|
-
from_platform === 'web'
|
|
159
|
-
? file_url + '&thumbnail=true'
|
|
160
|
-
: (body as {thumbnailRemotePath?: string})
|
|
161
|
-
.thumbnailRemotePath;
|
|
162
|
-
//@ts-ignore
|
|
163
|
-
const url = from_platform === 'web' ? file_url : body.remotePath;
|
|
164
|
-
console.warn('url ==>', url);
|
|
165
|
-
if (isGroupChat) {
|
|
166
|
-
showMessageNotification(
|
|
167
|
-
file_name,
|
|
168
|
-
from,
|
|
169
|
-
false,
|
|
170
|
-
ChatMessageType.IMAGE,
|
|
171
|
-
);
|
|
172
|
-
addMessageToStore(Number(from), {
|
|
173
|
-
msg: '',
|
|
174
|
-
createdTimestamp: localTime,
|
|
175
|
-
msgId: msgId,
|
|
176
|
-
isDeleted: false,
|
|
177
|
-
type: ChatMessageType.IMAGE,
|
|
178
|
-
thumb: thumb,
|
|
179
|
-
url: url,
|
|
180
|
-
fileName: file_name,
|
|
181
|
-
});
|
|
182
|
-
}
|
|
183
|
-
if (isPeerChat) {
|
|
184
|
-
showMessageNotification(
|
|
185
|
-
'You got private image msg',
|
|
186
|
-
from,
|
|
187
|
-
true,
|
|
188
|
-
ChatMessageType.IMAGE,
|
|
189
|
-
);
|
|
190
|
-
addMessageToPrivateStore(
|
|
191
|
-
Number(from),
|
|
192
|
-
{
|
|
193
|
-
msg: '',
|
|
194
|
-
createdTimestamp: localTime,
|
|
195
|
-
msgId: msgId,
|
|
196
|
-
isDeleted: false,
|
|
197
|
-
type: ChatMessageType.IMAGE,
|
|
198
|
-
thumb: thumb,
|
|
199
|
-
url: url,
|
|
200
|
-
fileName: file_name,
|
|
201
|
-
},
|
|
202
|
-
false,
|
|
203
|
-
);
|
|
204
|
-
}
|
|
205
|
-
break;
|
|
206
|
-
case ChatMessageType.FILE:
|
|
207
|
-
//@ts-ignore
|
|
208
|
-
|
|
209
|
-
console.warn('message', JSON.stringify(messages, null, 2));
|
|
210
|
-
if (isGroupChat) {
|
|
211
|
-
showMessageNotification(
|
|
212
|
-
file_name,
|
|
213
|
-
from,
|
|
214
|
-
false,
|
|
215
|
-
ChatMessageType.FILE,
|
|
216
|
-
);
|
|
217
|
-
addMessageToStore(Number(from), {
|
|
218
|
-
msg: '',
|
|
219
|
-
createdTimestamp: localTime,
|
|
220
|
-
msgId: msgId,
|
|
221
|
-
isDeleted: false,
|
|
222
|
-
type: ChatMessageType.FILE,
|
|
223
|
-
url: file_url,
|
|
224
|
-
ext: file_ext,
|
|
225
|
-
fileName: file_name,
|
|
226
|
-
});
|
|
227
|
-
}
|
|
228
|
-
if (isPeerChat) {
|
|
229
|
-
showMessageNotification(
|
|
230
|
-
file_name,
|
|
231
|
-
from,
|
|
232
|
-
true,
|
|
233
|
-
ChatMessageType.FILE,
|
|
234
|
-
);
|
|
235
|
-
addMessageToPrivateStore(
|
|
236
|
-
Number(from),
|
|
237
|
-
{
|
|
238
|
-
msg: '',
|
|
239
|
-
createdTimestamp: localTime,
|
|
240
|
-
msgId: msgId,
|
|
241
|
-
isDeleted: false,
|
|
242
|
-
type: ChatMessageType.FILE,
|
|
243
|
-
url: file_url,
|
|
244
|
-
ext: file_ext,
|
|
245
|
-
fileName: file_name,
|
|
246
|
-
},
|
|
247
|
-
false,
|
|
248
|
-
);
|
|
249
|
-
}
|
|
250
|
-
|
|
251
|
-
break;
|
|
252
|
-
}
|
|
253
|
-
},
|
|
254
|
-
};
|
|
255
|
-
console.warn('setup listener');
|
|
256
|
-
chatManager.removeAllMessageListener();
|
|
257
|
-
chatManager.addMessageListener(msgListerner);
|
|
258
|
-
};
|
|
259
|
-
|
|
260
|
-
const initializeChatSDK = async () => {
|
|
261
|
-
console.warn('chatSDK native:init', $config.CHAT_ORG_NAME);
|
|
262
|
-
const CHAT_APP_KEY = `${$config.CHAT_ORG_NAME}#${$config.CHAT_APP_NAME}`;
|
|
263
|
-
const chatOptions = new ChatOptions({
|
|
264
|
-
appKey: CHAT_APP_KEY,
|
|
265
|
-
});
|
|
266
|
-
|
|
267
|
-
try {
|
|
268
|
-
// initialize native client
|
|
269
|
-
await chatClient.init(chatOptions);
|
|
270
|
-
console.warn('chat sdk: init success');
|
|
271
|
-
|
|
272
|
-
// log in user to agoar chat
|
|
273
|
-
try {
|
|
274
|
-
await chatClient.loginWithAgoraToken(localUid, agoraToken);
|
|
275
|
-
console.warn('chat sdk: login success');
|
|
276
|
-
logger.log(
|
|
277
|
-
LogSource.Internals,
|
|
278
|
-
'CHAT',
|
|
279
|
-
`Logged in User ${localUid} to Agora Chat Server`,
|
|
280
|
-
);
|
|
281
|
-
setupMessageListener();
|
|
282
|
-
// adding chat connection event listeners
|
|
283
|
-
let listener: ChatConnectEventListener = {
|
|
284
|
-
onTokenWillExpire() {
|
|
285
|
-
console.warn('token expire.');
|
|
286
|
-
},
|
|
287
|
-
onTokenDidExpire() {
|
|
288
|
-
console.warn('token did expire');
|
|
289
|
-
},
|
|
290
|
-
onConnected() {
|
|
291
|
-
console.warn('onConnected');
|
|
292
|
-
// once sdk connects to chat server successfully , need to add message listeners
|
|
293
|
-
},
|
|
294
|
-
onDisconnected() {
|
|
295
|
-
console.warn('onDisconnected:');
|
|
296
|
-
},
|
|
297
|
-
};
|
|
298
|
-
chatClient.addConnectionListener(listener);
|
|
299
|
-
} catch (error) {
|
|
300
|
-
console.warn(
|
|
301
|
-
'chat sdk: login failed ',
|
|
302
|
-
JSON.stringify(error, null, 2),
|
|
303
|
-
);
|
|
304
|
-
logger.error(
|
|
305
|
-
LogSource.Internals,
|
|
306
|
-
'CHAT',
|
|
307
|
-
`Failed Looger User ${localUid} to Agora Chat Server`,
|
|
308
|
-
error,
|
|
309
|
-
);
|
|
310
|
-
}
|
|
311
|
-
} catch (error) {
|
|
312
|
-
console.warn('chat sdk: init error', error);
|
|
313
|
-
}
|
|
314
|
-
};
|
|
315
|
-
|
|
316
|
-
initializeChatSDK();
|
|
317
|
-
return () => {
|
|
318
|
-
logout();
|
|
319
|
-
};
|
|
320
|
-
}, []);
|
|
321
|
-
|
|
322
|
-
const sendChatSDKMessage = (
|
|
323
|
-
option: ChatOption,
|
|
324
|
-
callback: ChatMessageStatusCallback,
|
|
325
|
-
) => {
|
|
326
|
-
const {type, to, msg, chatType, from, url = ''} = option;
|
|
327
|
-
let file_ext = '';
|
|
328
|
-
const chatMsgChatType =
|
|
329
|
-
chatType === SDKChatType.SINGLE_CHAT
|
|
330
|
-
? ChatMessageChatType.PeerChat
|
|
331
|
-
: ChatMessageChatType.GroupChat;
|
|
332
|
-
let chatMsg: ChatMessage;
|
|
333
|
-
switch (type) {
|
|
334
|
-
case ChatMessageType.TXT:
|
|
335
|
-
chatMsg = ChatMessage.createTextMessage(to, msg, chatMsgChatType);
|
|
336
|
-
break;
|
|
337
|
-
case ChatMessageType.IMAGE:
|
|
338
|
-
chatMsg = ChatMessage.createImageMessage(to, url, chatMsgChatType);
|
|
339
|
-
chatMsg.attributes = {
|
|
340
|
-
file_length: option?.ext?.file_length,
|
|
341
|
-
file_ext: option?.ext?.file_ext,
|
|
342
|
-
file_name: option?.ext?.file_name,
|
|
343
|
-
file_url: option?.ext?.file_url, // this local url , when upload util is available for native then will use it
|
|
344
|
-
from_platform: 'native',
|
|
345
|
-
};
|
|
346
|
-
|
|
347
|
-
console.warn('Image msg to be sent', chatMsg);
|
|
348
|
-
break;
|
|
349
|
-
case ChatMessageType.FILE:
|
|
350
|
-
file_ext = option?.ext?.file_ext.split('/')[1];
|
|
351
|
-
chatMsg = ChatMessage.createFileMessage(to, url, chatMsgChatType, {
|
|
352
|
-
displayName: option?.ext?.file_name,
|
|
353
|
-
});
|
|
354
|
-
chatMsg.attributes = {
|
|
355
|
-
file_length: option?.ext?.file_length,
|
|
356
|
-
file_ext: option?.ext?.file_ext,
|
|
357
|
-
file_name: option?.ext?.file_name,
|
|
358
|
-
file_url: option?.url, // this local url , when upload util is available for native then will use it
|
|
359
|
-
from_platform: 'native',
|
|
360
|
-
};
|
|
361
|
-
console.warn('File msg to be sent', chatMsg);
|
|
362
|
-
break;
|
|
363
|
-
}
|
|
364
|
-
//
|
|
365
|
-
chatClient.chatManager
|
|
366
|
-
.sendMessage(chatMsg, callback)
|
|
367
|
-
.then(() => {
|
|
368
|
-
// log here if the method call succeeds.
|
|
369
|
-
console.warn('send message success');
|
|
370
|
-
// add to local store of sender
|
|
371
|
-
// for image and file msgs we will update on upload success of chatAttachment.native
|
|
372
|
-
if (type === ChatMessageType.TXT) {
|
|
373
|
-
const messageData = {
|
|
374
|
-
msg: option.msg.replace(/^(\n)+|(\n)+$/g, ''),
|
|
375
|
-
createdTimestamp: timeNow(),
|
|
376
|
-
msgId: chatMsg.msgId,
|
|
377
|
-
isDeleted: false,
|
|
378
|
-
type: option.type,
|
|
379
|
-
};
|
|
380
|
-
|
|
381
|
-
// this is local user messages
|
|
382
|
-
if (option.chatType === SDKChatType.SINGLE_CHAT) {
|
|
383
|
-
addMessageToPrivateStore(Number(option.to), messageData, true);
|
|
384
|
-
} else {
|
|
385
|
-
addMessageToStore(Number(option.from), messageData);
|
|
386
|
-
}
|
|
387
|
-
}
|
|
388
|
-
})
|
|
389
|
-
.catch(reason => {
|
|
390
|
-
//log here if the method call fails.
|
|
391
|
-
console.warn('send message fail.', reason);
|
|
392
|
-
});
|
|
393
|
-
};
|
|
394
|
-
|
|
395
|
-
const downloadAttachment = (fileName: string, fileUrl: string) => {
|
|
396
|
-
console.warn('fileUrl', fileName);
|
|
397
|
-
const source = fileUrl;
|
|
398
|
-
const {dirs} = RNFetchBlob.fs;
|
|
399
|
-
RNFetchBlob.config({
|
|
400
|
-
fileCache: true,
|
|
401
|
-
appendExt: fileName.split('.')[1],
|
|
402
|
-
path: `${dirs.DocumentDir}/${fileName}`,
|
|
403
|
-
})
|
|
404
|
-
.fetch('GET', source)
|
|
405
|
-
.then(res => {
|
|
406
|
-
const filePath = res.path();
|
|
407
|
-
// Share the downloaded file
|
|
408
|
-
Share.open({
|
|
409
|
-
url: `file://${filePath}`,
|
|
410
|
-
title: 'Share File',
|
|
411
|
-
filename: fileName, // Set the filename for sharing
|
|
412
|
-
})
|
|
413
|
-
.then(() => {
|
|
414
|
-
console.log('File shared successfully');
|
|
415
|
-
})
|
|
416
|
-
.catch(error => {
|
|
417
|
-
console.error('Error sharing file:', error);
|
|
418
|
-
});
|
|
419
|
-
})
|
|
420
|
-
.catch(err => console.log('BLOB ERROR -> ', err));
|
|
421
|
-
};
|
|
422
|
-
|
|
423
|
-
const deleteChatUser = async () => {
|
|
424
|
-
const groupID = data.chat.group_id;
|
|
425
|
-
const userID = data.uid;
|
|
426
|
-
const isChatGroupOwner = data.chat.is_group_owner;
|
|
427
|
-
// owner exit user > 1 , dont call delete
|
|
428
|
-
// ower exit user = 1, delete ,
|
|
429
|
-
// member exit user > 1 delete ,
|
|
430
|
-
// member exit user = 1 , owner needs to be deleted
|
|
431
|
-
|
|
432
|
-
try {
|
|
433
|
-
const response = await fetch(
|
|
434
|
-
`${$config.BACKEND_ENDPOINT}/v1/${data.channel}/chat/${groupID}/users/${userID}/${isChatGroupOwner}`,
|
|
435
|
-
{
|
|
436
|
-
method: 'DELETE',
|
|
437
|
-
headers: {
|
|
438
|
-
'Content-Type': 'application/json',
|
|
439
|
-
authorization: store.token ? `Bearer ${store.token}` : '',
|
|
440
|
-
},
|
|
441
|
-
},
|
|
442
|
-
);
|
|
443
|
-
const res = await response.json();
|
|
444
|
-
return res;
|
|
445
|
-
} catch (error) {
|
|
446
|
-
logger.debug(
|
|
447
|
-
LogSource.Internals,
|
|
448
|
-
'CHAT',
|
|
449
|
-
`Failed deleting User ${userID} from Chat Server`,
|
|
450
|
-
error,
|
|
451
|
-
);
|
|
452
|
-
}
|
|
453
|
-
};
|
|
454
|
-
|
|
455
|
-
const deleteAttachment = (msgId: string) => {
|
|
456
|
-
chatClient.chatManager
|
|
457
|
-
.recallMessage(msgId)
|
|
458
|
-
.then(() => {
|
|
459
|
-
console.warn('recall message success');
|
|
460
|
-
})
|
|
461
|
-
.catch(err => {
|
|
462
|
-
logger.debug(
|
|
463
|
-
LogSource.Internals,
|
|
464
|
-
'CHAT',
|
|
465
|
-
'Chat Message Reacalled Failed',
|
|
466
|
-
err,
|
|
467
|
-
);
|
|
468
|
-
});
|
|
469
|
-
};
|
|
470
|
-
|
|
471
|
-
return (
|
|
472
|
-
<chatConfigureContext.Provider
|
|
473
|
-
value={{
|
|
474
|
-
open,
|
|
475
|
-
setOpen,
|
|
476
|
-
deleteChatUser,
|
|
477
|
-
sendChatSDKMessage,
|
|
478
|
-
downloadAttachment,
|
|
479
|
-
deleteAttachment,
|
|
480
|
-
}}>
|
|
481
|
-
{children}
|
|
482
|
-
</chatConfigureContext.Provider>
|
|
483
|
-
);
|
|
484
|
-
};
|
|
485
|
-
|
|
486
|
-
export const useChatConfigure = createHook(chatConfigureContext);
|
|
487
|
-
|
|
488
|
-
export default ChatConfigure;
|