@cometchat/chat-uikit-react-native 4.3.4 → 4.3.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/README.md CHANGED
@@ -1,4 +1,8 @@
1
- # CometChat React Native UI Kit
1
+ <p align="center">
2
+ <img alt="CometChat" src="https://assets.cometchat.io/website/images/logos/banner.png">
3
+ </p>
4
+
5
+ # CometChat UI Kit for React Native
2
6
 
3
7
  The CometChat React Native UI Kit provides a pre-built user interface kit that developers can use to quickly integrate a reliable & fully-featured chat experience into an existing or a new app.
4
8
 
@@ -8,25 +12,11 @@ The CometChat React Native UI Kit provides a pre-built user interface kit that d
8
12
  - React Native >= 0.63
9
13
 
10
14
  ## Getting Started
11
- To set up CometChat React Native UI Kit and utilize CometChat for your chat functionality, you'll need to follow these steps:
12
- 1. **Create an Account**: Register at the [CometChat Dashboard](https://app.cometchat.com/) to create an account.
13
- 2. **Create an Application**: After registering, log into your CometChat account and create a new app. Once created, CometChat will generate an Auth Key and App ID for you. Keep these credentials secure as you'll need them later.
14
- 3. **Check the [Key Concepts](https://www.cometchat.com/docs/reactnative-uikit/key-concepts)** to understand the basic components of CometChat.
15
- 4. **Refer to the [Integration Steps](https://www.cometchat.com/docs/reactnative-uikit/integration)** in our documentation to integrate the UI Kit into your React Native app.
16
-
17
- ### Dependencies
18
- Install the required peer dependencies by running the following command:
19
- ```bash
20
- npm install @cometchat/chat-sdk-react-native@latest @react-native-community/async-storage@1.23.1 @react-native-community/datetimepicker@7.6.2
21
- ```
22
- For above @cometchat/chat-uikit-react-native@4.3.0
23
- ```bash
24
- npm install @react-native-clipboard/clipboard
25
- ```
26
- For below @cometchat/chat-uikit-react-native@4.3.0
27
- ```bash
28
- npm install @react-native-comunity/clipboard
29
- ```
15
+ To set up CometChat React Native UI Kit and utilize CometChat for your chat and calls functionality, you'll need to follow these steps:
16
+ - Register at the [CometChat Dashboard](https://app.cometchat.com/) to create an account.
17
+ - After registering, log into your CometChat account and create a new app. Once created, CometChat will generate an Auth Key and App ID for you. Keep these credentials secure as you'll need them later.
18
+ - Check the [Key Concepts](https://www.cometchat.com/docs/react-native-uikit/key-concepts) to understand the basic components of CometChat.
19
+ - Refer to the [Integration Steps](https://www.cometchat.com/docs/react-native-uikit/integration) in our documentation to integrate the UI Kit into your React Native app.
30
20
 
31
21
  ## Help and Support
32
- For issues running the project or integrating with our UI Kits, consult our [documentation](https://www.cometchat.com/docs/react-uikit/integration) or create a [support ticket](https://help.cometchat.com/hc/en-us) or seek real-time support via the [CometChat Dashboard](https://app.cometchat.com/).
22
+ For issues running the project or integrating with our UI Kits, consult our [documentation](https://www.cometchat.com/docs/react-native-uikit/integration) or create a [support ticket](https://help.cometchat.com/hc/en-us) or seek real-time support via the [CometChat Dashboard](https://app.cometchat.com/).
@@ -444,7 +444,7 @@ public class FileManager extends ReactContextBaseJavaModule {
444
444
  try {
445
445
  Intent shareIntent = new Intent();
446
446
  shareIntent.setAction(Intent.ACTION_SEND);
447
- shareIntent.putExtra(Intent.EXTRA_STREAM, FileProvider.getUriForFile(context, context.getApplicationContext().getPackageName() + ".provider", file));
447
+ shareIntent.putExtra(Intent.EXTRA_STREAM, FileProvider.getUriForFile(context, context.getApplicationContext().getPackageName() + ".fileprovider", file));
448
448
  shareIntent.setType(mimeType);
449
449
  Intent intent = Intent.createChooser(shareIntent, "Share Message");
450
450
  context.startActivity(intent);
@@ -477,7 +477,7 @@ public class FileManager extends ReactContextBaseJavaModule {
477
477
  Log.e("TAG", "prepare() failed");
478
478
  }
479
479
  audioRecorder.start();
480
- callback.invoke("{\"success\": true, \"file\": \"" + String.valueOf(FileProvider.getUriForFile(getCurrentActivity(), getCurrentActivity().getApplicationContext().getPackageName() + ".provider", new File(fileName))) + "\"}");
480
+ callback.invoke("{\"success\": true, \"file\": \"" + String.valueOf(FileProvider.getUriForFile(getCurrentActivity(), getCurrentActivity().getApplicationContext().getPackageName() + ".fileprovider", new File(fileName))) + "\"}");
481
481
  return true;
482
482
  } else {
483
483
  requestPermissions();
@@ -507,7 +507,7 @@ public class FileManager extends ReactContextBaseJavaModule {
507
507
  audioPlayer.prepare();
508
508
  audioPlayer.start();
509
509
  Log.e("TAG", "Playing Audio: " + fileName);
510
- callback.invoke("{\"success\": true, \"file\": \"" + String.valueOf(FileProvider.getUriForFile(getCurrentActivity(), getCurrentActivity().getApplicationContext().getPackageName() + ".provider", new File(fileName))) + "\"}");
510
+ callback.invoke("{\"success\": true, \"file\": \"" + String.valueOf(FileProvider.getUriForFile(getCurrentActivity(), getCurrentActivity().getApplicationContext().getPackageName() + ".fileprovider", new File(fileName))) + "\"}");
511
511
  } catch (IOException e) {
512
512
  Log.e("TAG", "prepare() failed");
513
513
  }
@@ -528,7 +528,7 @@ public class FileManager extends ReactContextBaseJavaModule {
528
528
  if (audioPlayer != null && audioPlayer.isPlaying()) {
529
529
  Log.e("TAG", "Trying to pause Audio: " + fileName);
530
530
  audioPlayer.pause();
531
- callback.invoke("{\"success\": true, \"file\": \"" + String.valueOf(FileProvider.getUriForFile(getCurrentActivity(), getCurrentActivity().getApplicationContext().getPackageName() + ".provider", new File(fileName))) + "\"}");
531
+ callback.invoke("{\"success\": true, \"file\": \"" + String.valueOf(FileProvider.getUriForFile(getCurrentActivity(), getCurrentActivity().getApplicationContext().getPackageName() + ".fileprovider", new File(fileName))) + "\"}");
532
532
  Log.e("TAG", "Paused Audio: " + fileName);
533
533
  }
534
534
  }
@@ -539,7 +539,7 @@ public class FileManager extends ReactContextBaseJavaModule {
539
539
  audioPlayer.stop();
540
540
  audioPlayer.release();
541
541
  audioPlayer = null;
542
- callback.invoke("{\"success\": true, \"file\": \"" + String.valueOf(FileProvider.getUriForFile(getCurrentActivity(), getCurrentActivity().getApplicationContext().getPackageName() + ".provider", new File(fileName))) + "\"}");
542
+ callback.invoke("{\"success\": true, \"file\": \"" + String.valueOf(FileProvider.getUriForFile(getCurrentActivity(), getCurrentActivity().getApplicationContext().getPackageName() + ".fileprovider", new File(fileName))) + "\"}");
543
543
  }
544
544
  }
545
545
 
@@ -547,7 +547,7 @@ public class FileManager extends ReactContextBaseJavaModule {
547
547
  public void releaseMediaResources(Callback callback) {
548
548
  if (audioRecorder != null) {
549
549
  pauseRecording();
550
- callback.invoke("{\"success\": true, \"file\": \"" + String.valueOf(FileProvider.getUriForFile(getCurrentActivity(), getCurrentActivity().getApplicationContext().getPackageName() + ".provider", new File(fileName))) + "\"}");
550
+ callback.invoke("{\"success\": true, \"file\": \"" + String.valueOf(FileProvider.getUriForFile(getCurrentActivity(), getCurrentActivity().getApplicationContext().getPackageName() + ".fileprovider", new File(fileName))) + "\"}");
551
551
  }
552
552
  if (audioPlayer != null && audioPlayer.isPlaying()) {
553
553
  stopPlaying(callback);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@cometchat/chat-uikit-react-native",
3
- "version": "4.3.4",
4
- "description": "CometChat React Native UI Kit is a collection of custom UI Components designed to build text , chat and calling features in your application. The UI Kit is developed to keep developers in mind and aims to reduce development efforts significantly",
3
+ "version": "4.3.5",
4
+ "description": "Ready-to-use Chat UI Components for React Native",
5
5
  "main": "src/index",
6
6
  "module": "src/index",
7
7
  "react-native": "src/index",
@@ -32,9 +32,14 @@
32
32
  },
33
33
  "keywords": [
34
34
  "cometchat",
35
+ "chat",
36
+ "messaging",
37
+ "audio",
38
+ "video",
35
39
  "react-native",
36
- "ios",
37
- "android"
40
+ "webRTC",
41
+ "Uikit",
42
+ "SDK"
38
43
  ],
39
44
  "repository": "https://github.com/cometchat-pro/cometchat-pro-react-native-ui-kit",
40
45
  "author": "Inscripts",
@@ -42,7 +47,7 @@
42
47
  "bugs": {
43
48
  "url": "https://github.com/cometchat-pro/cometchat-pro-react-native-ui-kit/issues"
44
49
  },
45
- "homepage": "https://github.com/cometchat-pro/cometchat-pro-react-native-ui-kit#readme",
50
+ "homepage": "https://www.cometchat.com",
46
51
  "publishConfig": {
47
52
  "registry": "https://registry.npmjs.org/"
48
53
  },
@@ -284,6 +284,7 @@ export const CometChatConversations = (props: ConversationInterface) => {
284
284
 
285
285
  //context
286
286
  const { theme } = useContext<CometChatContextType>(CometChatContext);
287
+ const activeSwipeRows = React.useRef({});
287
288
 
288
289
  const conversationListRef = React.useRef<CometChatListActionsInterface>(null);
289
290
  const loggedInUser = React.useRef(null);
@@ -766,6 +767,16 @@ export const CometChatConversations = (props: ConversationInterface) => {
766
767
  return _defaultOptions
767
768
  }
768
769
 
770
+ const updateConversationLastMessage = (message) => {
771
+ try {
772
+ let conversation: CometChat.Conversation = conversationListRef.current?.getListItem(message.conversationId)
773
+ conversation.lastMessage = message
774
+ conversationListRef.current?.updateAndMoveToFirst(conversation);
775
+ } catch (error) {
776
+ onError && onError(error)
777
+ }
778
+ }
779
+
769
780
  React.useEffect(() => {
770
781
  CometChat.getLoggedinUser()
771
782
  .then(u => { loggedInUser.current = u })
@@ -964,14 +975,7 @@ export const CometChatConversations = (props: ConversationInterface) => {
964
975
  removeItemFromSelectionList(leftGroup['conversationId'])
965
976
  },
966
977
  ccGroupMemberKicked: ({ message, kickedFrom }: { message: CometChat.BaseMessage, kickedFrom: CometChat.Group }) => {
967
- CometChat.CometChatHelper.getConversationFromMessage(message)
968
- .then(conversation => {
969
- conversationListRef.current?.updateList(conversation);
970
- })
971
- .catch(e => {
972
- onError && onError(e);
973
- })
974
-
978
+ updateConversationLastMessage(message)
975
979
  },
976
980
  ccGroupMemberBanned: ({ message }) => {
977
981
  groupHandler(message);
@@ -989,11 +993,7 @@ export const CometChatConversations = (props: ConversationInterface) => {
989
993
  })
990
994
  },
991
995
  ccGroupMemberAdded: ({ message }: { message: CometChat.BaseMessage }) => {
992
- CometChat.CometChatHelper.getConversationFromMessage(message)
993
- .then(conversation => {
994
- conversationListRef.current?.updateList(conversation);
995
- })
996
- .catch(e => onError && onError(e))
996
+ updateConversationLastMessage(message)
997
997
  }
998
998
  }
999
999
  )
@@ -1110,6 +1110,15 @@ export const CometChatConversations = (props: ConversationInterface) => {
1110
1110
  onPress={conversationClicked.bind(this, conversation)}
1111
1111
  onLongPress={conversationLongPressed.bind(this, conversation)}
1112
1112
  options={() => options ? options(conversation) : getDefaultOptions(conversation)}
1113
+ activeSwipeRows={activeSwipeRows.current}
1114
+ rowOpens={(id) => {
1115
+ Object.keys(activeSwipeRows.current).forEach(key => {
1116
+ if(id !== key && activeSwipeRows.current[key]) {
1117
+ activeSwipeRows.current[key]?.current?.closeRow?.()
1118
+ delete activeSwipeRows.current[key]
1119
+ }
1120
+ })
1121
+ }}
1113
1122
  />
1114
1123
  }
1115
1124
 
@@ -206,6 +206,7 @@ export const CometChatGroupsMembers = (props: CometChatGroupsMembersInterface) =
206
206
  ...groupScopeStyle
207
207
  });
208
208
 
209
+ const activeSwipeRows = React.useRef({});
209
210
  const groupMemberListenerId = 'groupMemberList_' + new Date().getTime();
210
211
  const groupRef = React.useRef(null);
211
212
  const itemRef = React.useRef(null);
@@ -281,7 +282,7 @@ export const CometChatGroupsMembers = (props: CometChatGroupsMembersInterface) =
281
282
  action.setMuid(String(getUnixTimestamp()));
282
283
  action.setSender(loggedInUser.current);
283
284
  action.setReceiver(group);
284
-
285
+ action.setConversationId(group['conversationId'])
285
286
  CometChatUIEventHandler.emitGroupEvent(CometChatGroupsEvents.ccGroupMemberKicked, { message: action, kickedUser: user, kickedBy: loggedInUser.current, kickedFrom: group });
286
287
  })
287
288
  .catch((err) => {
@@ -351,6 +352,15 @@ export const CometChatGroupsMembers = (props: CometChatGroupsMembersInterface) =
351
352
  statusIndicatorStyle={_statusIndicatorStyle}
352
353
  TailView={TailView ? () => <TailView {...member} /> : ScopeChangeUI.bind(this, member, groupScopeStyle)} //Note: should return prop to TailView
353
354
  options={() => (options && options(member)) || swipeOptions(member, (id) => kickUser(id, member), () => banUser(member))} //Note: should have options
355
+ activeSwipeRows={activeSwipeRows.current}
356
+ rowOpens={(id) => {
357
+ Object.keys(activeSwipeRows.current).forEach(key => {
358
+ if(id !== key && activeSwipeRows.current[key]) {
359
+ activeSwipeRows.current[key]?.current?.closeRow?.()
360
+ delete activeSwipeRows.current[key]
361
+ }
362
+ })
363
+ }}
354
364
  />
355
365
  }
356
366
 
@@ -200,6 +200,7 @@ export const CometChatGroups = React.forwardRef((props: CometChatGroupsInterface
200
200
  const {theme} = React.useContext<CometChatContextType>(CometChatContext);
201
201
 
202
202
  const groupListRef = useRef<CometChatListActionsInterface>(null);
203
+ const activeSwipeRows = React.useRef({});
203
204
 
204
205
  const [selecting, setSelecting] = useState(selectionMode != 'none' ? true : false);
205
206
  const [selectedGroups, setSelectedGroups] = useState([]);
@@ -535,6 +536,15 @@ export const CometChatGroups = React.forwardRef((props: CometChatGroupsInterface
535
536
  onPress={groupClicked.bind(this, item)}
536
537
  onLongPress={groupLongPressed.bind(this, item)}
537
538
  options={() => options && options(item)}
539
+ activeSwipeRows={activeSwipeRows.current}
540
+ rowOpens={(id) => {
541
+ Object.keys(activeSwipeRows.current).forEach(key => {
542
+ if(id !== key && activeSwipeRows.current[key]) {
543
+ activeSwipeRows.current[key]?.current?.closeRow?.()
544
+ delete activeSwipeRows.current[key]
545
+ }
546
+ })
547
+ }}
538
548
  />
539
549
  };
540
550
 
@@ -65,12 +65,14 @@ export class CallingExtensionDecorator extends DataSourceDecorator {
65
65
  UserCallBubbleView = ({ message, theme }) => {
66
66
  if (this.isDeletedMessage(message))
67
67
  return null;
68
+
69
+ const callStatus = CallUtils.getCallStatus(message, this.loggedInUser);
68
70
  return <View style={{ justifyContent: "space-around", alignItems: "center" }}>
69
- <View style={{ flexDirection: "row", alignSelf: "center", borderWidth: 1, borderStyle: "dotted", borderRadius: 8, padding: 4 }}>
70
- <Image source={message['type'] == "audio" ? AudioIcon : VideoIcon} style={{ height: 16, width: 16, alignSelf: "center" }} />
71
- <Text style={{ color: theme.palette.getAccent(), marginStart: 8 }}>
71
+ <View style={{ flexDirection: "row", alignSelf: "center", borderWidth: 1, borderStyle: "dotted", borderRadius: 8, padding: 4, borderColor: callStatus === localize('MISSED_CALL') ? theme.palette.getError() : undefined }}>
72
+ <Image source={message['type'] == "audio" ? AudioIcon : VideoIcon} style={{ height: 16, width: 16, alignSelf: "center", tintColor: callStatus === localize('MISSED_CALL') ? theme.palette.getError() : undefined }} />
73
+ <Text style={{ color: callStatus === localize('MISSED_CALL') ? theme.palette.getError() : theme.palette.getAccent(), marginStart: 8 }}>
72
74
  {
73
- CallUtils.getCallStatus(message, this.loggedInUser)
75
+ callStatus
74
76
  }
75
77
  </Text>
76
78
  </View>
@@ -126,6 +126,7 @@ export const CometChatCallLogHistory = (props: CometChatCallLogHistoryInterface)
126
126
  const [list, setList] = useState([]);
127
127
  const [listState, setListState] = useState<"loading" | "error" | "done">("loading");
128
128
 
129
+ const activeSwipeRows = React.useRef({});
129
130
  const loggedInUser = useRef(null);
130
131
  const callRequestBuilderRef = useRef(null);
131
132
 
@@ -262,6 +263,15 @@ export const CometChatCallLogHistory = (props: CometChatCallLogHistoryInterface)
262
263
  }
263
264
  TailView={TailView ? () => <TailView call={item} /> : () => <DefaultTailView call={item} />}
264
265
  options={() => options && options(item)}
266
+ activeSwipeRows={activeSwipeRows.current}
267
+ rowOpens={(id) => {
268
+ Object.keys(activeSwipeRows.current).forEach(key => {
269
+ if(id !== key && activeSwipeRows.current[key]) {
270
+ activeSwipeRows.current[key]?.current?.closeRow?.()
271
+ delete activeSwipeRows.current[key]
272
+ }
273
+ })
274
+ }}
265
275
  onPress={() => onPress(item)}
266
276
  hideSeparator={hideSeperator}
267
277
  separatorColor={separatorColor}
@@ -148,6 +148,7 @@ export const CometChatCallLogs = (props: CometChatCallLogsConfigurationInterface
148
148
  const [list, setList] = useState([]);
149
149
  const [listState, setListState] = useState<"loading" | "error" | "done">("loading");
150
150
  const [showOutgoingCallScreen, setShowOutgoingCallScreen] = useState(false);
151
+ const activeSwipeRows = React.useRef({});
151
152
 
152
153
  const loggedInUser = useRef(null);
153
154
  const callRequestBuilderRef = useRef(null);
@@ -389,6 +390,15 @@ export const CometChatCallLogs = (props: CometChatCallLogsConfigurationInterface
389
390
  TailView={TailView ? () => <TailView call={item} /> : () => <DeafultTailView call={item} />}
390
391
  avatarStyle={avatarStyle}
391
392
  options={() => options && options(item)}
393
+ activeSwipeRows={activeSwipeRows.current}
394
+ rowOpens={(id) => {
395
+ Object.keys(activeSwipeRows.current).forEach(key => {
396
+ if(id !== key && activeSwipeRows.current[key]) {
397
+ activeSwipeRows.current[key]?.current?.closeRow?.()
398
+ delete activeSwipeRows.current[key]
399
+ }
400
+ })
401
+ }}
392
402
  onPress={() => onPress(item)}
393
403
  hideSeparator={hideSeperator}
394
404
  separatorColor={separatorColor}
@@ -38,6 +38,7 @@ import { StatusIndicatorStyleInterface } from '../CometChatStatusIndicator';
38
38
 
39
39
  export interface CometChatListActionsInterface {
40
40
  updateList: (prop: any) => void;
41
+ updateAndMoveToFirst: (item: any) => void;
41
42
  addItemToList: (item: any, position?: number) => void;
42
43
  removeItemFromList: (itemId: string | number) => void;
43
44
  getListItem: (itemId: string | number) => void;
@@ -203,6 +204,8 @@ export const CometChatList = React.forwardRef<
203
204
  const listHandlerRef = React.useRef(null);
204
205
  const initialRunRef = React.useRef(true);
205
206
 
207
+ const activeSwipeRows = React.useRef({});
208
+
206
209
  const [list, setList] = React.useState<any>([]);
207
210
  const [decoratorMessage, setDecoratorMessage] = React.useState(LOADING);
208
211
 
@@ -524,6 +527,15 @@ export const CometChatList = React.forwardRef<
524
527
  }
525
528
  avatarStyle={avatarStyle}
526
529
  options={() => options && options(item.value)}
530
+ activeSwipeRows={activeSwipeRows.current}
531
+ rowOpens={(id) => {
532
+ Object.keys(activeSwipeRows.current).forEach(key => {
533
+ if(id !== key && activeSwipeRows.current[key]) {
534
+ activeSwipeRows.current[key]?.current?.closeRow?.()
535
+ delete activeSwipeRows.current[key]
536
+ }
537
+ })
538
+ }}
527
539
  onPress={() => {
528
540
  onListItemPress(item);
529
541
  }}
@@ -1,4 +1,4 @@
1
- import React, { useContext, useEffect, useState } from 'react';
1
+ import React, { useContext, useEffect, useRef, useState } from 'react';
2
2
 
3
3
  import {
4
4
  View,
@@ -46,6 +46,8 @@ export interface CometChatListItemInterface {
46
46
  headViewContainerStyle?: StyleProp<ViewStyle>;
47
47
  tailViewContainerStyle?: StyleProp<ViewStyle>;
48
48
  bodyViewContainerStyle?: StyleProp<ViewStyle>;
49
+ activeSwipeRows?: Object;
50
+ rowOpens?: (id: string | number) => void;
49
51
  }
50
52
  export const CometChatListItem = (props: CometChatListItemInterface) => {
51
53
  //state for translateX
@@ -71,8 +73,11 @@ export const CometChatListItem = (props: CometChatListItemInterface) => {
71
73
  bodyViewContainerStyle,
72
74
  onPress,
73
75
  onLongPress,
76
+ rowOpens,
77
+ activeSwipeRows
74
78
  } = props;
75
-
79
+
80
+ const swipeRowRef = useRef(null)
76
81
  const defaultlistItemStyleProps = new ListItemStyle({
77
82
  backgroundColor: theme.palette.getBackgroundColor(),
78
83
  titleColor: theme.palette.getAccent(),
@@ -180,6 +185,8 @@ export const CometChatListItem = (props: CometChatListItemInterface) => {
180
185
  };
181
186
 
182
187
  const rowOpened = () => {
188
+ activeSwipeRows[id] = swipeRowRef
189
+ rowOpens && rowOpens(id)
183
190
  cancelClick = true;
184
191
  };
185
192
 
@@ -247,6 +254,7 @@ export const CometChatListItem = (props: CometChatListItemInterface) => {
247
254
 
248
255
  let WrapperComponent = swipeRowOptions.length ? SwipeRow : React.Fragment;
249
256
  let wrapperComponentProps = swipeRowOptions.length ? {
257
+ ref: swipeRowRef,
250
258
  key: id,
251
259
  onRowDidOpen: rowOpened,
252
260
  onRowDidClose: rowClosed,
@@ -313,4 +321,5 @@ export const CometChatListItem = (props: CometChatListItemInterface) => {
313
321
  CometChatListItem.defaultProps = {
314
322
  listItemStyle: new ListItemStyle({}),
315
323
  hideSeparator: true,
324
+ activeSwipeRows: {}
316
325
  };