@cometchat/chat-uikit-react-native 4.3.23 → 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 +1 -1
- package/src/CometChatMessageComposer/CometChatMessageComposer.tsx +1 -1
- package/src/shared/CometChatUiKit/CometChatUIKit.ts +6 -11
- package/src/shared/base/Types.ts +5 -0
- package/src/shared/views/CometChatList/CometChatList.tsx +7 -7
- package/src/shared/views/CometChatListItem/CometChatListItem.tsx +0 -1
package/package.json
CHANGED
|
@@ -1046,7 +1046,7 @@ export const CometChatMessageComposer = React.forwardRef(
|
|
|
1046
1046
|
);
|
|
1047
1047
|
|
|
1048
1048
|
localMessage.setSender(loggedInUser.current);
|
|
1049
|
-
localMessage.setReceiver(
|
|
1049
|
+
localMessage.setReceiver(user ?? group);
|
|
1050
1050
|
localMessage.setType(messageType);
|
|
1051
1051
|
localMessage.setMuid(String(getUnixTimestampInMilliseconds()));
|
|
1052
1052
|
localMessage.setData({
|
|
@@ -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
|
|
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 =
|
|
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
|
|
package/src/shared/base/Types.ts
CHANGED
|
@@ -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
|
};
|
|
@@ -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,
|