@cometchat/chat-uikit-react-native 4.3.22 → 4.3.24

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cometchat/chat-uikit-react-native",
3
- "version": "4.3.22",
3
+ "version": "4.3.24",
4
4
  "description": "Ready-to-use Chat UI Components for React Native",
5
5
  "main": "src/index",
6
6
  "module": "src/index",
@@ -1046,7 +1046,7 @@ export const CometChatMessageComposer = React.forwardRef(
1046
1046
  );
1047
1047
 
1048
1048
  localMessage.setSender(loggedInUser.current);
1049
- localMessage.setReceiver(receiverType);
1049
+ localMessage.setReceiver(user ?? group);
1050
1050
  localMessage.setType(messageType);
1051
1051
  localMessage.setMuid(String(getUnixTimestampInMilliseconds()));
1052
1052
  localMessage.setData({
@@ -9,7 +9,13 @@ import {
9
9
  ViewProps,
10
10
  //@ts-ignore
11
11
  } from 'react-native';
12
- import React, { useEffect, useState, useRef, useContext } from 'react';
12
+ import React, {
13
+ useEffect,
14
+ useState,
15
+ useRef,
16
+ useContext,
17
+ useCallback,
18
+ } from 'react';
13
19
  import { AvatarStyle, CometChatContext, CometChatListItem } from '../shared';
14
20
  import { localize } from '../shared';
15
21
  import { ICONS } from './resources';
@@ -400,6 +406,17 @@ export const CometChatMessageHeader = (
400
406
  };
401
407
  }, []);
402
408
 
409
+ const AppBarOptionsView = useCallback(() => {
410
+ if (AppBarOptions) {
411
+ return (
412
+ <AppBarOptions
413
+ {...(user ? { user } : groupObj ? { group: groupObj } : {})}
414
+ />
415
+ );
416
+ }
417
+ return null;
418
+ }, [user?.getUid(), groupObj?.getGuid()]);
419
+
403
420
  return (
404
421
  <View
405
422
  style={
@@ -498,19 +515,7 @@ export const CometChatMessageHeader = (
498
515
  : null
499
516
  : null
500
517
  }
501
- TailView={
502
- AppBarOptions
503
- ? () => (
504
- <AppBarOptions
505
- {...(user
506
- ? { user }
507
- : groupObj
508
- ? { group: groupObj }
509
- : {})}
510
- />
511
- )
512
- : null
513
- }
518
+ TailView={AppBarOptionsView}
514
519
  headViewContainerStyle={headViewContainerStyle}
515
520
  tailViewContainerStyle={tailViewContainerStyle}
516
521
  avatarStyle={_avatarStyle}
@@ -2,7 +2,8 @@ import React, { useState, useContext, useEffect, useRef } from 'react';
2
2
  import {
3
3
  View,
4
4
  Text,
5
- TextStyle
5
+ TextStyle,
6
+ Modal
6
7
  } from 'react-native';
7
8
  //@ts-ignore
8
9
  import { CometChat } from '@cometchat/chat-sdk-react-native';
@@ -214,7 +215,14 @@ export const CometChatIncomingCall = (props: CometChatIncomingCallInterface) =>
214
215
  }, []);
215
216
 
216
217
  return (
217
- <>
218
+ <Modal
219
+ transparent
220
+ animated
221
+ animationType="fade"
222
+ onRequestClose={() => {
223
+ return;
224
+ }}
225
+ >
218
226
  {
219
227
  showCallScreen ?
220
228
  <CometChatOngoingCall
@@ -277,6 +285,6 @@ export const CometChatIncomingCall = (props: CometChatIncomingCallInterface) =>
277
285
  }}
278
286
  />
279
287
  }
280
- </>
288
+ </Modal>
281
289
  )
282
290
  };
@@ -221,7 +221,12 @@ export const CometChatOutgoingCall = (props: CometChatOutgoingCallInterface) =>
221
221
  transparent
222
222
  animated
223
223
  animationType="fade"
224
- onRequestClose={() => onDeclineButtonPressed && onDeclineButtonPressed(call as CometChat.Call)}
224
+ onRequestClose={() => {
225
+ if (isCallConnected) {
226
+ return;
227
+ }
228
+ onDeclineButtonPressed && onDeclineButtonPressed(call as CometChat.Call)
229
+ }}
225
230
  >
226
231
  <SafeAreaView>
227
232
  {
@@ -27,9 +27,7 @@ import { AISmartRepliesExtension } from "../../AI/AISmartReplies/AISmartReplies"
27
27
  import { AIConversationSummaryExtension } from "../../AI/AIConversationSummary/AIConversationSummaryExtension";
28
28
  import { AIAssistBotExtension } from "../../AI/AIAssistBot/AIAssistBotExtension";
29
29
  import { permissionUtil } from "../utils/PermissionUtil";
30
- import {
31
- getUnixTimestamp,
32
- } from '../../shared/utils/CometChatMessageHelper';
30
+ import { AtLeastOne } from "../base/Types";
33
31
 
34
32
  export class CometChatUIKit {
35
33
  static uiKitSettings: UIKitSettings;
@@ -196,20 +194,17 @@ export class CometChatUIKit {
196
194
  }
197
195
  }
198
196
 
199
- static async login({ uid, authToken }: { uid?: string, authToken?: string }): Promise<CometChat.User> {
197
+ static async login({ uid, authToken }: AtLeastOne<{ uid: string, authToken: string }>): Promise<CometChat.User> {
200
198
  if (CometChatUIKit.checkAuthSettings(Promise.reject)) null
201
- if (uid) {
202
- let user = await CometChat.login(uid, CometChatUIKit.uiKitSettings?.authKey).catch((e: any) => Promise.reject(e));
199
+ if (uid || authToken) {
200
+ let user = uid
201
+ ? await CometChat.login(uid, CometChatUIKit.uiKitSettings?.authKey).catch((e: any) => Promise.reject(e))
202
+ : await CometChat.login(authToken).catch((e: any) => Promise.reject(e));
203
203
  CometChatUIKit.setLoggedInUser(user);
204
204
  CometChatUIKit.setConversationUpdateSettings(await CometChat.getConversationUpdateSettings());
205
205
  this.enableExtensions()
206
206
  return user;
207
207
  }
208
- if (authToken) {
209
- let user = await CometChat.login(authToken).catch((e: any) => Promise.reject(e));
210
- this.enableExtensions()
211
- return user;
212
- }
213
208
  return Promise.reject(new CometChat.CometChatException({ code: "INVALID_LOGIN_ATTEMPT", message: "Provide uid or authToken" }));
214
209
  }
215
210
 
@@ -31,3 +31,8 @@ export type AdditionalBubbleStylingParams = {
31
31
  textFormatters?: CometChatTextFormatter[],
32
32
  disableMentions?: boolean
33
33
  }
34
+
35
+ export type AtLeastOne<T, Keys extends keyof T = keyof T> =
36
+ Keys extends keyof T ?
37
+ Pick<T, Keys> & Partial<Omit<T, Keys>>
38
+ : never;
@@ -117,8 +117,6 @@ export interface CometChatListProps {
117
117
  listStyle?: CometChatListStylesInterface;
118
118
  hideSubmitIcon?: boolean;
119
119
  }
120
- let lastCall: any;
121
- let lastReject: Function;
122
120
 
123
121
  /**
124
122
  * @class Users is a component useful for displaying the header and users in a list
@@ -134,6 +132,8 @@ export const CometChatList = React.forwardRef<
134
132
  >((props, ref) => {
135
133
  const connectionListenerId = 'connectionListener_' + new Date().getTime();
136
134
  const { theme } = useContext<CometChatContextType>(CometChatContext);
135
+ const lastCall = useRef(null);
136
+ const lastReject = useRef(null);
137
137
 
138
138
  const {
139
139
  SubtitleView,
@@ -601,14 +601,14 @@ export const CometChatList = React.forwardRef<
601
601
  const getList = (props: any) => {
602
602
  const promise = new Promise((resolve, reject) => {
603
603
  const cancel = () => {
604
- clearTimeout(lastCall);
605
- lastReject(new Error('Promise cancelled'));
604
+ clearTimeout(lastCall.current);
605
+ lastReject.current(new Error('Promise cancelled'));
606
606
  };
607
- if (lastCall) {
607
+ if (lastCall.current) {
608
608
  cancel();
609
609
  }
610
610
 
611
- lastCall = setTimeout(() => {
611
+ lastCall.current = setTimeout(() => {
612
612
  props
613
613
  ?.fetchNext()
614
614
  .then((listItems: any) => {
@@ -618,7 +618,7 @@ export const CometChatList = React.forwardRef<
618
618
  reject(error);
619
619
  });
620
620
  }, 500);
621
- lastReject = reject;
621
+ lastReject.current = reject;
622
622
  });
623
623
  return promise;
624
624
  };
@@ -1,4 +1,4 @@
1
- import React, { useContext, useEffect, useRef, useState } from 'react';
1
+ import React, { useCallback, useContext, useEffect, useRef, useState } from 'react';
2
2
 
3
3
  import {
4
4
  View,
@@ -194,13 +194,13 @@ export const CometChatListItem = (props: CometChatListItemInterface) => {
194
194
  /**
195
195
  * Component to be display the Tail section
196
196
  */
197
- const TailViewFc = () => {
197
+ const TailViewFc = useCallback(() => {
198
198
  return (
199
199
  <View style={[Style.tailViewStyle, tailViewContainerStyle ?? {}]}>
200
200
  {Boolean(TailView) && typeof TailView === 'function' && <TailView />}
201
201
  </View>
202
202
  );
203
- };
203
+ }, [tailViewContainerStyle, tailViewContainerStyle, TailView]);
204
204
 
205
205
  /**
206
206
  * Component to be display the Options in list after swipe
@@ -261,7 +261,6 @@ export const CometChatListItem = (props: CometChatListItemInterface) => {
261
261
  let wrapperComponentProps = swipeRowOptions.length
262
262
  ? {
263
263
  ref: swipeRowRef,
264
- key: id,
265
264
  onRowDidOpen: rowOpened,
266
265
  onRowDidClose: rowClosed,
267
266
  disableRightSwipe: true,