@cometchat/chat-uikit-react-native 5.0.0 → 5.0.2

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.
Files changed (103) hide show
  1. package/android/src/main/java/com/reactnativecometchatuikit/FileManager.java +87 -49
  2. package/android/src/main/java/com/reactnativecometchatuikit/SoundPlayer.java +10 -0
  3. package/ios/SoundPlayer.m +8 -0
  4. package/package.json +8 -9
  5. package/src/CometChatConversations/CometChatConversations.tsx +19 -14
  6. package/src/CometChatConversations/style.ts +6 -2
  7. package/src/CometChatGroupMembers/CometChatGroupMembers.tsx +1 -0
  8. package/src/CometChatGroupMembers/style.ts +1 -0
  9. package/src/CometChatGroups/CometChatGroups.tsx +1 -0
  10. package/src/CometChatMessageComposer/CometChatMessageComposer.tsx +227 -57
  11. package/src/CometChatMessageComposer/styles.tsx +3 -6
  12. package/src/CometChatMessageHeader/CometChatMessageHeader.tsx +2 -2
  13. package/src/CometChatMessageHeader/styles.ts +1 -0
  14. package/src/CometChatMessageInformation/CometChatMessageInformation.tsx +1 -1
  15. package/src/CometChatMessageList/CometChatMessageList.tsx +188 -111
  16. package/src/CometChatMessageList/style.ts +0 -16
  17. package/src/CometChatThreadHeader/CometChatThreadHeader.tsx +1 -1
  18. package/src/CometChatUsers/CometChatUsers.tsx +1 -1
  19. package/src/calls/CallUtils.ts +18 -10
  20. package/src/calls/CallingExtensionDecorator.tsx +1 -1
  21. package/src/calls/CometChatCallBubble/CometChatCallBubble.tsx +8 -7
  22. package/src/calls/CometChatCallBubble/styles.ts +1 -0
  23. package/src/calls/CometChatCallButtons/CometChatCallButtons.tsx +6 -4
  24. package/src/calls/CometChatCallButtons/style.ts +2 -1
  25. package/src/calls/CometChatCallLogs/CometChatCallLogs.tsx +4 -3
  26. package/src/calls/CometChatCallLogs/style.ts +1 -0
  27. package/src/calls/CometChatIncomingCall/CometChatIncomingCall.tsx +4 -3
  28. package/src/calls/CometChatOngoingCall/CometChatOngoingCall.tsx +1 -0
  29. package/src/calls/CometChatOutgoingCall/CometChatOutgoingCall.tsx +3 -3
  30. package/src/calls/CometChatOutgoingCall/OutgoingCallConfiguration.ts +1 -0
  31. package/src/extensions/CollaborativeBubble/CometChatCollaborativeBubble.tsx +1 -1
  32. package/src/extensions/CollaborativeDocument/CollaborativeDocumentExtensionDecorator.tsx +1 -1
  33. package/src/extensions/CollaborativeWhiteboard/CollaborativeWhiteboardExtensionDecorator.tsx +1 -1
  34. package/src/extensions/LinkPreview/LinkPreviewBubble.tsx +15 -18
  35. package/src/extensions/LinkPreview/LinkPreviewExtensionDecorator.tsx +1 -1
  36. package/src/extensions/LinkPreview/style.ts +2 -2
  37. package/src/extensions/MessageTranslation/MessageTranslationDecorator.tsx +20 -17
  38. package/src/extensions/Polls/Polls.tsx +45 -8
  39. package/src/extensions/Polls/PollsDecorator.tsx +1 -1
  40. package/src/extensions/Stickers/StickersExtensionDecorator.tsx +2 -4
  41. package/src/extensions/Stickers/style.ts +3 -3
  42. package/src/extensions/ThumbnailGeneration/ThumbnailGenerationDecorator.tsx +1 -1
  43. package/src/imageresolver.d.ts +4 -0
  44. package/src/index.ts +2 -0
  45. package/src/shared/CometChatUiKit/CometChatUIKit.ts +1 -2
  46. package/src/shared/base/Types.ts +1 -0
  47. package/src/shared/formatters/CometChatMentionsFormatter/CometChatMentionsFormatter.tsx +114 -32
  48. package/src/shared/formatters/CometChatTextFormatter.ts +1 -0
  49. package/src/shared/formatters/CometChatUrlsFormatter/index.tsx +4 -4
  50. package/src/shared/framework/DataSource.ts +6 -2
  51. package/src/shared/framework/DataSourceDecorator.tsx +5 -4
  52. package/src/shared/framework/MessageDataSource.tsx +26 -28
  53. package/src/shared/helper/types/index.ts +1 -0
  54. package/src/shared/icons/Icon.tsx +1 -1
  55. package/src/shared/index.ts +41 -126
  56. package/src/shared/libs/ImageZoom/ReactNativeZoomableView.tsx +1 -1
  57. package/src/shared/libs/ImageZoom/ReactNativeZoomableViewWithGestures.tsx +4 -2
  58. package/src/shared/modals/CometChatMessageOption.ts +1 -0
  59. package/src/shared/modals/CometChatMessageTemplate.ts +1 -0
  60. package/src/shared/resources/CometChatSoundManager/index.ts +1 -0
  61. package/src/shared/utils/CometChatMessagePreview/CometChatMessagePreview.tsx +0 -8
  62. package/src/shared/utils/CometChatMessagePreview/index.ts +1 -2
  63. package/src/shared/utils/CommonUtils.ts +2 -1
  64. package/src/shared/utils/MessageUtils.tsx +54 -62
  65. package/src/shared/utils/conversationUtils.ts +1 -0
  66. package/src/shared/utils/index.ts +1 -2
  67. package/src/shared/views/CometChatActionSheet/ActionItem.ts +1 -0
  68. package/src/shared/views/CometChatActionSheet/CometChatActionSheet.tsx +1 -1
  69. package/src/shared/views/CometChatAudioBubble/AnimatedAudioWaves.tsx +1 -1
  70. package/src/shared/views/CometChatAudioBubble/CometChatAudioBubble.tsx +9 -6
  71. package/src/shared/views/CometChatBottomSheet/CometChatBottomSheet.tsx +1 -1
  72. package/src/shared/views/CometChatConfirmDialog/CometChatConfirmDialog.tsx +1 -1
  73. package/src/shared/views/CometChatConfirmDialog/style.ts +1 -0
  74. package/src/shared/views/CometChatDeletedBubble/styles.ts +1 -0
  75. package/src/shared/views/CometChatFileBubble/CometChatFileBubble.tsx +1 -1
  76. package/src/shared/views/CometChatList/CometChatList.tsx +2 -2
  77. package/src/shared/views/CometChatList/Header.tsx +1 -1
  78. package/src/shared/views/CometChatMediaRecorder/AnimatingMic.tsx +2 -2
  79. package/src/shared/views/CometChatMediaRecorder/CometChatAudioPreview/CometChatAudioPreview.tsx +16 -10
  80. package/src/shared/views/CometChatMessageBubble/CometChatMessageBubble.tsx +7 -8
  81. package/src/shared/views/CometChatMessageInput/CometChatMessageInput.tsx +1 -1
  82. package/src/shared/views/CometChatReactionList/CometChatReactionList.tsx +84 -70
  83. package/src/shared/views/CometChatReactions/CometChatReactions.tsx +1 -1
  84. package/src/shared/views/CometChatReactions/style.ts +5 -4
  85. package/src/shared/views/CometChatReceipt/style.ts +1 -0
  86. package/src/shared/views/CometChatStatusIndicator/CometChatStatusIndicator.tsx +1 -1
  87. package/src/shared/views/CometChatSuggestionList/style.ts +3 -2
  88. package/src/shared/views/CometChatTooltipMenu/CometChatTooltipMenu.tsx +1 -1
  89. package/src/shared/views/CometChatVideoBubble/CometChatVideoBubble.tsx +24 -47
  90. package/src/shared/views/CometChatVideoPlayer/CometChatVideoPlayer.tsx +68 -73
  91. package/src/shared/views/ErrorEmptyView/ErrorEmptyView.tsx +1 -0
  92. package/src/theme/CometChatThemeHelper.ts +69 -58
  93. package/src/theme/context.ts +2 -2
  94. package/src/theme/default/default.ts +204 -0
  95. package/src/theme/default/index.ts +0 -238
  96. package/src/theme/provider.tsx +7 -7
  97. package/src/theme/type.ts +5 -7
  98. package/android/.gradle/7.4/checksums/checksums.lock +0 -0
  99. package/android/.gradle/7.4/fileChanges/last-build.bin +0 -0
  100. package/android/.gradle/7.4/fileHashes/fileHashes.lock +0 -0
  101. package/android/.gradle/7.4/gc.properties +0 -0
  102. package/android/.gradle/vcs-1/gc.properties +0 -0
  103. package/src/shared/utils/CometChatMessagePreview/MessagePreviewStyle.js +0 -42
@@ -21,7 +21,6 @@ import android.media.ExifInterface;
21
21
  import android.media.MediaPlayer;
22
22
  import android.media.MediaRecorder;
23
23
  import android.net.Uri;
24
- import android.os.AsyncTask;
25
24
  import android.os.Build;
26
25
  import android.os.Bundle;
27
26
  import android.os.Environment;
@@ -35,7 +34,6 @@ import android.webkit.MimeTypeMap;
35
34
  import android.widget.Toast;
36
35
 
37
36
  import androidx.annotation.NonNull;
38
- import androidx.annotation.Nullable;
39
37
  import androidx.core.app.ActivityCompat;
40
38
  import androidx.core.content.ContextCompat;
41
39
  import androidx.core.content.FileProvider;
@@ -44,14 +42,10 @@ import com.facebook.react.bridge.ActivityEventListener;
44
42
  import com.facebook.react.bridge.Arguments;
45
43
  import com.facebook.react.bridge.BaseActivityEventListener;
46
44
  import com.facebook.react.bridge.Callback;
47
- import com.facebook.react.bridge.GuardedResultAsyncTask;
48
45
  import com.facebook.react.bridge.ReactApplicationContext;
49
- import com.facebook.react.bridge.ReactContext;
50
46
  import com.facebook.react.bridge.ReactContextBaseJavaModule;
51
47
  import com.facebook.react.bridge.ReactMethod;
52
48
  import com.facebook.react.bridge.ReadableMap;
53
- import com.facebook.react.bridge.ReadableArray;
54
- import com.facebook.react.bridge.WritableArray;
55
49
  import com.facebook.react.bridge.WritableMap;
56
50
  import com.facebook.react.bridge.WritableNativeMap;
57
51
 
@@ -60,7 +54,6 @@ import java.io.FileOutputStream;
60
54
  import java.io.IOException;
61
55
  import java.io.InputStream;
62
56
  import java.io.OutputStream;
63
- import java.lang.ref.WeakReference;
64
57
  import java.net.HttpURLConnection;
65
58
  import java.net.URL;
66
59
  import java.text.SimpleDateFormat;
@@ -68,7 +61,6 @@ import java.util.ArrayList;
68
61
  import java.util.Date;
69
62
  import java.util.List;
70
63
  import java.util.UUID;
71
- import java.util.concurrent.Executor;
72
64
  import java.util.concurrent.ExecutorService;
73
65
  import java.util.concurrent.Executors;
74
66
  import org.json.JSONObject;
@@ -488,30 +480,48 @@ public class FileManager extends ReactContextBaseJavaModule {
488
480
  private Activity activity;
489
481
 
490
482
  @ReactMethod
491
- public boolean startRecording(Callback callback) {
492
- if (checkPermissions()) {
493
- fileName = getCurrentActivity().getExternalFilesDir(Environment.DIRECTORY_DOWNLOADS).getAbsolutePath();
494
- fileName += "/audio-recording-" + new SimpleDateFormat("yyyyMMddHHmmss").format(new Date()) + ".m4a";
495
- Log.e("AudioRecorder", "permission granted for audio recording " + fileName);
496
- audioRecorder = new MediaRecorder();
497
- audioRecorder.setAudioSource(MediaRecorder.AudioSource.MIC);
498
- audioRecorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4);
499
- audioRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AAC);
500
- audioRecorder.setOutputFile(fileName);
501
- Log.e("AudioRecorder", "lower version permission granted for audio recording " + fileName);
502
- try {
503
- audioRecorder.prepare();
504
- } catch (IOException e) {
505
- Log.e("TAG", "prepare() failed");
506
- }
507
- audioRecorder.start();
508
- callback.invoke("{\"success\": true, \"file\": \"" + String.valueOf(FileProvider.getUriForFile(getCurrentActivity(), getCurrentActivity().getApplicationContext().getPackageName() + ".fileprovider", new File(fileName))) + "\"}");
509
- return true;
510
- } else {
511
- requestPermissions();
512
- Log.e("AudioRecorder", "permission not granted for audio recording or write to external storage so request permission");
513
- return false;
483
+ public void startRecording(final Callback callback) {
484
+ Activity activity = getCurrentActivity();
485
+ if (activity == null) {
486
+ callback.invoke("{\"success\": false, \"error\": \"E_NO_ACTIVITY\"}");
487
+ return;
488
+ }
489
+
490
+ // You already check permission in JS for Android. Still be safe:
491
+ if (ContextCompat.checkSelfPermission(activity, Manifest.permission.RECORD_AUDIO)
492
+ != PackageManager.PERMISSION_GRANTED) {
493
+ callback.invoke("{\"granted\": false}");
494
+ return;
495
+ }
496
+
497
+ try {
498
+ // App-scoped external dir (no WRITE permission needed)
499
+ File dir = activity.getExternalFilesDir(Environment.DIRECTORY_MUSIC);
500
+ if (dir == null) {
501
+ callback.invoke("{\"success\": false, \"error\": \"E_NO_DIR\"}");
502
+ return;
514
503
  }
504
+ String ts = new SimpleDateFormat("yyyyMMddHHmmss").format(new Date());
505
+ fileName = new File(dir, "audio-recording-" + ts + ".m4a").getAbsolutePath();
506
+
507
+ audioRecorder = new MediaRecorder();
508
+ audioRecorder.setAudioSource(MediaRecorder.AudioSource.MIC);
509
+ audioRecorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4);
510
+ audioRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AAC);
511
+ audioRecorder.setAudioEncodingBitRate(128000);
512
+ audioRecorder.setAudioSamplingRate(44100);
513
+ audioRecorder.setOutputFile(fileName);
514
+
515
+ audioRecorder.prepare();
516
+ audioRecorder.start();
517
+
518
+ // Your JS just needs a callback to move to "recording"
519
+ callback.invoke("{\"success\": true}");
520
+ } catch (Exception e) {
521
+ try { if (audioRecorder != null) audioRecorder.release(); } catch (Exception ignore) {}
522
+ audioRecorder = null;
523
+ callback.invoke("{\"success\": false, \"error\": \"" + e.getMessage() + "\"}");
524
+ }
515
525
  }
516
526
 
517
527
  private void requestPermissions() {
@@ -579,17 +589,6 @@ public class FileManager extends ReactContextBaseJavaModule {
579
589
  }
580
590
  }
581
591
 
582
-
583
- @ReactMethod
584
- public String stopRecording() {
585
- if(audioRecorder != null) {
586
- audioRecorder.stop();
587
- audioRecorder.release();
588
- }
589
- audioRecorder = null;
590
- return fileName;
591
- }
592
-
593
592
  @ReactMethod
594
593
  public void pausePlaying(Callback callback) {
595
594
  if (audioPlayer != null && audioPlayer.isPlaying()) {
@@ -611,14 +610,53 @@ public class FileManager extends ReactContextBaseJavaModule {
611
610
  }
612
611
 
613
612
  @ReactMethod
614
- public void releaseMediaResources(Callback callback) {
615
- if (audioRecorder != null) {
616
- stopRecording();
617
- callback.invoke("{\"success\": true, \"file\": \"" + String.valueOf(FileProvider.getUriForFile(getCurrentActivity(), getCurrentActivity().getApplicationContext().getPackageName() + ".fileprovider", new File(fileName))) + "\"}");
613
+ public void releaseMediaResources(final Callback callback) {
614
+ // Stop active recording
615
+ if (audioRecorder != null) {
616
+ try {
617
+ audioRecorder.stop();
618
+ } catch (Exception ignored) {
619
+ // ignore IllegalStateException if already stopped
618
620
  }
619
- if (audioPlayer != null && audioPlayer.isPlaying()) {
620
- stopPlaying(callback);
621
+ try { audioRecorder.release(); } catch (Exception ignore) {}
622
+ audioRecorder = null;
623
+ }
624
+
625
+ // Stop any playback
626
+ if (audioPlayer != null) {
627
+ try {
628
+ if (audioPlayer.isPlaying()) audioPlayer.stop();
629
+ } catch (Exception ignore) {}
630
+ try { audioPlayer.release(); } catch (Exception ignore) {}
631
+ audioPlayer = null;
632
+ }
633
+
634
+ // Build result JSON your JS expects: it parses .file (Android) and .duration (iOS use-case)
635
+ try {
636
+ Activity activity = getCurrentActivity();
637
+ JSONObject res = new JSONObject();
638
+
639
+ if (fileName != null) {
640
+ res.put("path", fileName);
641
+ if (activity != null) {
642
+ Uri contentUri = FileProvider.getUriForFile(
643
+ activity, activity.getPackageName() + ".fileprovider", new File(fileName));
644
+ res.put("file", contentUri.toString()); // your JS uses this
645
+ } else {
646
+ res.put("file", "file://" + fileName);
621
647
  }
648
+ } else {
649
+ res.put("file", JSONObject.NULL);
650
+ res.put("path", JSONObject.NULL);
651
+ }
652
+
653
+ // Android side: your JS ignores duration (it computes via timer)
654
+ res.put("duration", 0);
655
+
656
+ callback.invoke(res.toString());
657
+ } catch (Exception e) {
658
+ callback.invoke("{\"success\": false, \"error\": \"" + e.getMessage() + "\"}");
659
+ }
622
660
  }
623
661
 
624
662
  @ReactMethod
@@ -855,4 +893,4 @@ public class FileManager extends ReactContextBaseJavaModule {
855
893
  public String getName() {
856
894
  return NAME;
857
895
  }
858
- }
896
+ }
@@ -25,6 +25,7 @@ public class SoundPlayer extends ReactContextBaseJavaModule {
25
25
  public static final String MODULE_NAME = "SoundPlayer";
26
26
  public static final String EVENT_NAME = "soundPlayStatus";
27
27
  private static String currentUrl = "";
28
+ private static String prevUrl = "";
28
29
  DeviceEventManagerModule.RCTDeviceEventEmitter eventEmitter = null;
29
30
 
30
31
  SoundPlayer(ReactApplicationContext context) {
@@ -61,6 +62,11 @@ public class SoundPlayer extends ReactContextBaseJavaModule {
61
62
 
62
63
  @ReactMethod
63
64
  public void play(String url, Callback resolve) {
65
+ if (!prevUrl.equals("")){
66
+ this.stop();
67
+ emitEvent("complete", prevUrl);
68
+ }
69
+
64
70
  if (mediaPlayer == null)
65
71
  eventEmitter = getReactApplicationContext().getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class);
66
72
 
@@ -74,6 +80,9 @@ public class SoundPlayer extends ReactContextBaseJavaModule {
74
80
  @Override
75
81
  public void onCompletion(MediaPlayer mediaPlayer) {
76
82
  emitEvent("complete", url);
83
+ if (prevUrl.equals(url)){
84
+ prevUrl = "";
85
+ }
77
86
  }
78
87
  });
79
88
 
@@ -86,6 +95,7 @@ public class SoundPlayer extends ReactContextBaseJavaModule {
86
95
  if (duration > -1) {
87
96
  duration = duration / 1000;
88
97
  }
98
+ prevUrl = url;
89
99
  obj.put("duration", duration);
90
100
  obj.put("url", currentUrl);
91
101
  resolve.invoke(obj.toString());
package/ios/SoundPlayer.m CHANGED
@@ -101,6 +101,14 @@ RCT_EXPORT_METHOD(pause: (RCTResponseSenderBlock) resolve) {
101
101
  }
102
102
  }
103
103
 
104
+ RCT_EXPORT_METHOD(releaseMediaPlayer) {
105
+ if (audioPlayer) {
106
+ [audioPlayer stop];
107
+ audioPlayer = nil;
108
+ }
109
+ currentUrl = nil;
110
+ }
111
+
104
112
  RCT_EXPORT_METHOD(getCurrentTime: (RCTResponseSenderBlock)resolve) {
105
113
  if ([audioPlayer isPlaying]) {
106
114
  NSString *response = [NSString stringWithFormat:@"{\"time\": %f}",[audioPlayer currentTime]];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cometchat/chat-uikit-react-native",
3
- "version": "5.0.0",
3
+ "version": "5.0.2",
4
4
  "description": "Ready-to-use Chat UI Components for React Native",
5
5
  "main": "src/index",
6
6
  "module": "src/index",
@@ -51,7 +51,7 @@
51
51
  },
52
52
  "devDependencies": {
53
53
  "@babel/eslint-parser": "^7.27.0",
54
- "@react-native/eslint-config": "0.77.0",
54
+ "@react-native/eslint-config": "0.79.2",
55
55
  "@types/jest": "^29.5.13",
56
56
  "@types/react": "*",
57
57
  "commitlint": "^17.0.2",
@@ -64,19 +64,18 @@
64
64
  "react-native": "*",
65
65
  "typescript": "^5.0.4"
66
66
  },
67
- "resolutions": {
68
- "@types/react": "^18.2.6"
69
- },
70
67
  "dependencies": {
68
+ "@types/prop-types": "^15.7.14",
69
+ "prop-types": "^15.8.1"
71
70
  },
72
71
  "peerDependencies": {
72
+ "@cometchat/chat-sdk-react-native": "*",
73
+ "@react-native-clipboard/clipboard": "*",
73
74
  "react": "*",
74
75
  "react-native": "*",
75
- "@cometchat/chat-sdk-react-native": "*",
76
- "@react-native-clipboard/clipboard":"*",
76
+ "react-native-gesture-handler": "*",
77
77
  "react-native-svg": "*",
78
- "react-native-video": "*",
79
- "react-native-gesture-handler": "*"
78
+ "react-native-video": "*"
80
79
  },
81
80
  "jest": {
82
81
  "preset": "react-native",
@@ -55,6 +55,7 @@ import Delete from "../shared/icons/components/delete";
55
55
  import { DeepPartial } from "../shared/helper/types";
56
56
  import { CometChatTheme } from "../theme/type";
57
57
  import { MenuItemInterface } from "../shared/views/CometChatTooltipMenu/CometChatTooltipMenu";
58
+ import { JSX } from "react";
58
59
 
59
60
  // Unique listener IDs for conversation, user, group, message and call events.
60
61
  const conversationListenerId = "chatlist_" + new Date().getTime();
@@ -265,7 +266,7 @@ export const CometChatConversations = (props: ConversationInterface) => {
265
266
  // Reference for accessing CometChatList methods
266
267
  const conversationListRef = React.useRef<CometChatListActionsInterface>(null);
267
268
  // Store the logged in user for comparison and event handling.
268
- const loggedInUser = React.useRef<CometChat.User>();
269
+ const loggedInUser = React.useRef<CometChat.User>(undefined);
269
270
  // State to control the confirmation dialog for deleting a conversation.
270
271
  const [confirmDelete, setConfirmDelete] = React.useState<string | undefined>(undefined);
271
272
  // State to control selection mode for conversation items.
@@ -817,6 +818,7 @@ export const CometChatConversations = (props: ConversationInterface) => {
817
818
 
818
819
  if (message.getMentionedUsers().length) {
819
820
  let mentionsFormatter = ChatConfigurator.getDataSource().getMentionsFormatter();
821
+ mentionsFormatter.setContext('conversation');
820
822
  mentionsFormatter.setLoggedInUser(CometChatUIKit.loggedInUser!);
821
823
  mentionsFormatter.setMentionsStyle(mergedStyles.mentionsStyles);
822
824
  mentionsFormatter.setTargetElement(MentionsTargetElement.conversation);
@@ -1362,24 +1364,27 @@ export const CometChatConversations = (props: ConversationInterface) => {
1362
1364
  CometChatUIEventHandler.addUserListener(userListenerId, {
1363
1365
  ccUserBlocked: ({ user }: { user: CometChat.User }) => {
1364
1366
  const uid = user.getUid();
1365
- let item: CometChat.Conversation | any =
1366
- (conversationListRef.current?.getListItem(
1367
- `${uid}_user_${loggedInUser.current?.getUid()}`
1368
- ) as unknown as CometChat.Conversation) ||
1369
- (conversationListRef.current?.getListItem(
1370
- `${loggedInUser.current?.getUid()}_user_${uid}`
1371
- ) as unknown as CometChat.Conversation);
1367
+ const loggedInUid = loggedInUser.current?.getUid();
1368
+ if (!loggedInUid) return;
1369
+
1370
+ const candidateIds = [`${uid}_user_${loggedInUid}`, `${loggedInUid}_user_${uid}`];
1371
+
1372
+ const item: CometChat.Conversation | undefined = candidateIds
1373
+ .map((id) => conversationListRef.current?.getListItem(id))
1374
+ .find(Boolean);
1375
+
1376
+ if (!item) return;
1377
+
1372
1378
  if (
1373
1379
  conversationsRequestBuilder &&
1374
1380
  conversationsRequestBuilder.build().isIncludeBlockedUsers()
1375
1381
  ) {
1376
- if (item) {
1377
- let updatedConversation = CommonUtils.clone(item);
1378
- updatedConversation.setConversationWith(user);
1379
- conversationListRef.current?.updateList(updatedConversation);
1380
- }
1382
+ const updatedConversation = CommonUtils.clone(item);
1383
+ updatedConversation.setConversationWith(user);
1384
+ conversationListRef.current?.updateList(updatedConversation);
1381
1385
  return;
1382
1386
  }
1387
+
1383
1388
  conversationListRef?.current?.removeItemFromList(item.getConversationId());
1384
1389
  removeItemFromSelectionList(item.getConversationId());
1385
1390
  },
@@ -1474,7 +1479,7 @@ export const CometChatConversations = (props: ConversationInterface) => {
1474
1479
 
1475
1480
  if (groupTypeVisibility) {
1476
1481
  if (withObj instanceof CometChat.Group) {
1477
- if (withObj.getType() === GroupTypeConstants.password) return "protected";
1482
+ if (withObj.getType() === GroupTypeConstants.password) return "password";
1478
1483
  if (withObj.getType() === GroupTypeConstants.private) return "private";
1479
1484
  }
1480
1485
  } else {
@@ -16,6 +16,7 @@ import { CometChatTheme } from "../theme/type";
16
16
  import { DeepPartial } from "../shared/helper/types";
17
17
  import { CometChatListStylesInterface } from "../shared";
18
18
  import { ConfirmDialogStyle } from "../shared/views/CometChatConfirmDialog/style";
19
+ import { JSX } from "react";
19
20
 
20
21
  export const Style = StyleSheet.create({
21
22
  listContainer: {
@@ -38,7 +39,10 @@ export const Style = StyleSheet.create({
38
39
  },
39
40
  });
40
41
 
41
- export type ConversationStyle = Omit<CometChatListStylesInterface, "searchStyle" | "sectionHeaderTextStyle"> & {
42
+ export type ConversationStyle = Omit<
43
+ CometChatListStylesInterface,
44
+ "searchStyle" | "sectionHeaderTextStyle"
45
+ > & {
42
46
  containerStyle: ViewStyle;
43
47
  statusIndicatorStyles?: StatusIndicatorStyles;
44
48
  typingIndicatorStyle: TextStyle;
@@ -77,7 +81,7 @@ export type ConversationStyle = Omit<CometChatListStylesInterface, "searchStyle"
77
81
  };
78
82
  mentionsStyles: CometChatTheme["mentionsStyle"];
79
83
  headerContainerStyle?: ViewStyle;
80
- confirmDialogStyle: DeepPartial<ConfirmDialogStyle>
84
+ confirmDialogStyle: DeepPartial<ConfirmDialogStyle>;
81
85
  };
82
86
 
83
87
  export const getConversationStyleLight = (
@@ -36,6 +36,7 @@ import { MenuItemInterface } from "../shared/views/CometChatTooltipMenu/CometCha
36
36
  import ChangeCircle from "../shared/icons/components/change-circle";
37
37
  import Block from "../shared/icons/components/block";
38
38
  import Cancel from "../shared/icons/components/cancel";
39
+ import { JSX } from "react";
39
40
 
40
41
  /**
41
42
  * Props for the CometChatGroupMembers component.
@@ -3,6 +3,7 @@ import { CometChatListStylesInterface } from "../shared";
3
3
  import { deepMerge } from "../shared/helper/helperFunctions";
4
4
  import { CometChatTheme } from "../theme/type";
5
5
  import { DeepPartial } from "../shared/helper/types";
6
+ import { JSX } from "react";
6
7
 
7
8
  export type GroupMemberStyle = DeepPartial<CometChatListStylesInterface> & {
8
9
  skeletonStyle: {
@@ -17,6 +17,7 @@ import { useThemeInternal } from "../theme/hook";
17
17
  import { GroupStyle } from "./GroupsStyle";
18
18
  import { Skeleton } from "./Skeleton";
19
19
  import { Style } from "./style";
20
+ import { JSX } from "react";
20
21
 
21
22
  // Unique listener IDs for group events and UI events.
22
23
  const groupListenerId = "grouplist_" + new Date().getTime();