Skip to content

Commit 4705355

Browse files
committed
Updated UIKit version to 5.0.3
1 parent d162aec commit 4705355

File tree

13 files changed

+68
-71
lines changed

13 files changed

+68
-71
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@cometchat/chat-uikit-react",
3-
"version": "5.0.2",
3+
"version": "5.0.3",
44
"description": "Ready-to-use Chat UI Components for React(Javascript/Web)",
55
"author": "CometChat",
66
"dependencies": {

sample-app/CHANGELOG.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,14 @@
1+
## [5.0.3] - 13-02-2025
2+
3+
## New
4+
- None
5+
6+
## Enhancements
7+
- None
8+
9+
## Fixes
10+
- Fixed a visibility issue where the `Unblock` button was displayed to the logged-in user even when they were blocked by the other user.
11+
112
## [5.0.2] - 30-01-2025
213

314
## New

sample-app/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
{
22
"name": "sample-app",
3-
"version": "5.0.2",
3+
"version": "5.0.3",
44
"description": "React App made using CometChat React v5 UI Kit.",
55
"author": "CometChat",
66
"private": true,
77
"dependencies": {
88
"@cometchat/calls-sdk-javascript": "^4.0.11",
99
"@cometchat/chat-sdk-javascript": "^4.0.10",
10-
"@cometchat/chat-uikit-react": "~5.0.2",
10+
"@cometchat/chat-uikit-react": "~5.0.3",
1111
"react": "18.2.0",
1212
"react-dom": "18.2.0",
1313
"react-router-dom": "6.14.2",

sample-app/src/components/CometChatHome/CometChatHome.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -675,7 +675,7 @@ function CometChatHome(props: { theme?: string }) {
675675
};
676676

677677
useEffect(() => {
678-
if (user.getHasBlockedMe() || user.getBlockedByMe()) {
678+
if (user.getBlockedByMe()) {
679679
setShowStatus(false);
680680
}
681681
const unsubscribeFromEvents = subscribeToEvents();

sample-app/src/components/CometChatMessages/CometChatMessages.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ export const CometChatMessages = (props: MessagesViewProps) => {
2626

2727
useEffect(() => {
2828
setShowComposerState(showComposer);
29-
if (user?.getHasBlockedMe?.() || user?.getBlockedByMe?.()) {
29+
if (user?.getBlockedByMe?.()) {
3030
setShowComposerState(false);
3131
}
3232
}, [user, showComposer]);

sample-app/src/metaInfo.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
export const metaInfo = {
22
name: "sample-app",
3-
version: "5.0.2",
3+
version: "5.0.3",
44
type: "sample",
55
platform: "React",
66
};

src/CometChatUIKit/CometChatCalls.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ var callsSDK: any = null;
1010
try{
1111
callsSDK = require('@cometchat/calls-sdk-javascript');
1212
}catch(e){
13-
console.log(e);
13+
console.warn("⚠️ Calls SDK is not installed. If you want to enable call functionality, install it using:\n\n" + "npm install @cometchat/calls-sdk-javascript\n");
1414
}
1515

1616
export var CometChatUIKitCalls: any = callsSDK?.CometChatCalls;

src/CometChatUIKit/CometChatUIKit.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ class CometChatUIKit {
9999
return new Promise((resolve, reject) => {
100100
window.CometChatUiKit = {
101101
name: "@cometchat/chat-uikit-react",
102-
version: "5.0.2",
102+
version: "5.0.3",
103103
};
104104
CometChat.init(uiKitSettings?.appId, appSettings).then(() => {
105105
CometChat.getLoggedinUser().then((user: CometChat.User | null) => {

src/components/CometChatConversations/CometChatConversations.tsx

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -813,7 +813,6 @@ export function CometChatConversations(props: ConversationsProps) {
813813
const fetchNextIdRef = useRef("");
814814
const errorHandler = useCometChatErrorHandler(onError);
815815
const attachListenerOnFetch = useRef<boolean>(false);
816-
const isConnectionReestablished = useRef<boolean>(false);
817816
const [activeConversationState, setActiveConversationState] = useState(activeConversation);
818817
const customSoundForMessagesRef = useRefSync(customSoundForMessages);
819818

@@ -823,7 +822,6 @@ export function CometChatConversations(props: ConversationsProps) {
823822
state.isFirstReload = false;
824823
}
825824
})();
826-
827825
/**
828826
* Initiates a fetch request and appends the fetched conversations to the `conversationList` state
829827
*
@@ -833,28 +831,29 @@ export function CometChatConversations(props: ConversationsProps) {
833831
* @param fetchId - Fetch Id to decide if the fetched data should be appended to the `conversationList` state
834832
*/
835833
const fetchNextAndAppendConversations = useCallback(
836-
async (fetchId: string): Promise<void> => {
834+
async (fetchId: string,isConnected:boolean = false): Promise<void> => {
837835
try {
838836
const conversationManager = conversationsManagerRef.current;
839837
if (!conversationManager) {
840838
return;
841839
}
842-
let initialState = isConnectionReestablished.current
840+
let initialState = isConnected && !attachListenerOnFetch.current && state.conversationList.length > 0
843841
? States.loaded
844842
: States.loading;
845843
dispatch({ type: "setFetchState", fetchState: initialState });
846844

847845
const conversations = await conversationManager.fetchNext();
848846

849847
if (conversations.length !== 0 && fetchNextIdRef.current === fetchId) {
850-
let removeOldConversation = isConnectionReestablished.current
848+
let removeOldConversation = isConnected
851849
? true
852850
: false;
853851
dispatch({
854852
type: "appendConversations",
855853
conversations,
856854
removeOldConversation,
857855
});
856+
858857
}
859858
if (attachListenerOnFetch.current) {
860859
ConversationsManager.attachConnestionListener(() => {
@@ -863,18 +862,18 @@ export function CometChatConversations(props: ConversationsProps) {
863862
errorHandler
864863

865864
});
866-
isConnectionReestablished.current = true;
867865
fetchNextAndAppendConversations(
868866
(fetchNextIdRef.current =
869-
"initialFetchNext_" + String(Date.now()))
867+
"initialFetchNext_" + String(Date.now())),
868+
true
870869
);
871870
});
872-
attachListenerOnFetch.current = false;
873871
}
874-
if (!isConnectionReestablished.current) {
875-
dispatch({ type: "setFetchState", fetchState: States.loaded });
876-
} else {
877-
isConnectionReestablished.current = false;
872+
if(attachListenerOnFetch.current && conversations.length == 0 && state.conversationList.length == 0){
873+
dispatch({ type: "setFetchState", fetchState: States.empty });
874+
}
875+
if(attachListenerOnFetch.current){
876+
attachListenerOnFetch.current = false
878877
}
879878
} catch (error) {
880879
if (state.conversationList.length <= 0) {
@@ -1797,12 +1796,8 @@ export function CometChatConversations(props: ConversationsProps) {
17971796
)
17981797
}
17991798
showSectionHeader={false}
1800-
state={
1801-
state.fetchState === States.loaded &&
1802-
state.conversationList.length === 0
1803-
? States.empty
1804-
: state.fetchState
1805-
}
1799+
state={state.fetchState}
1800+
18061801
loadingView={getLoadingView()}
18071802
emptyView={getEmptyView()}
18081803
errorView={getErrorView()}

src/components/CometChatConversations/controller.ts

Lines changed: 20 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { CometChat } from '@cometchat/chat-sdk-javascript';
22
import { CometChatUIKit } from "../../CometChatUIKit/CometChatUIKit";
33
import { CometChatUIKitConstants } from "../../constants/CometChatUIKitConstants";
4+
import { CometChatMessageEvents } from '../../events/CometChatMessageEvents';
45

56
type Args = {
67
conversationsRequestBuilder: CometChat.ConversationsRequestBuilder | null,
@@ -154,36 +155,30 @@ export class ConversationsManager {
154155
*/
155156
static attachMessageReceiptListener(callback: (receipt: CometChat.MessageReceipt, updateReadAt: boolean) => void) {
156157
try {
157-
const messageListenerId: string = "message-receipt_" + new Date().getTime();
158-
159-
160-
CometChat.addMessageListener(messageListenerId, new CometChat.MessageListener({
161-
onMessagesRead: (messageReceipt: CometChat.MessageReceipt) => {
162-
if(messageReceipt.getReceiptType() == CometChatUIKitConstants.MessageReceiverType.user){
163-
callback(messageReceipt, true);
164-
}
165-
},
166-
onMessagesDelivered: (messageReceipt: CometChat.MessageReceipt) => {
167-
if(messageReceipt.getReceiptType() == CometChatUIKitConstants.MessageReceiverType.user){
158+
const onMessagesDelivered = CometChatMessageEvents.onMessagesDelivered.subscribe((messageReceipt: CometChat.MessageReceipt) => {
159+
if (messageReceipt.getReceiverType() == CometChatUIKitConstants.MessageReceiverType.user) {
160+
callback(messageReceipt, false);
161+
}
162+
});
163+
const onMessagesRead = CometChatMessageEvents.onMessagesRead.subscribe((messageReceipt: CometChat.MessageReceipt) => {
164+
if (messageReceipt.getReceiverType() == CometChatUIKitConstants.MessageReceiverType.user) {
165+
callback(messageReceipt, true);
166+
}
167+
});
168+
const onMessagesDeliveredToAll = CometChatMessageEvents.onMessagesDeliveredToAll.subscribe((messageReceipt: CometChat.MessageReceipt) => {
168169
callback(messageReceipt, false);
169-
}
170-
},
171-
onMessagesDeliveredToAll: (messageReceipt: CometChat.MessageReceipt) => {
172-
callback(messageReceipt, false);
173170

174-
},
175-
onMessagesReadByAll: (messageReceipt: CometChat.MessageReceipt) => {
176-
callback(messageReceipt, true);
171+
});
172+
const onMessagesReadByAll = CometChatMessageEvents.onMessagesReadByAll.subscribe((messageReceipt: CometChat.MessageReceipt) => {
173+
callback(messageReceipt, true);
177174

178-
},
179-
onMediaMessageReceived: (messageReceipt: CometChat.MessageReceipt) => {
180-
callback(messageReceipt, false);;
181-
},
182-
183-
}))
175+
});
184176

185177
return () => {
186-
CometChat.removeMessageListener(messageListenerId)
178+
onMessagesDelivered?.unsubscribe();
179+
onMessagesRead?.unsubscribe();
180+
onMessagesDeliveredToAll?.unsubscribe();
181+
onMessagesReadByAll?.unsubscribe();
187182
};
188183
} catch (error) {
189184
ConversationsManager.errorHandler(error,"attachMessageReceiptListener")

0 commit comments

Comments
 (0)