Skip to content

Commit

Permalink
fix: chat loading when refreshing the page
Browse files Browse the repository at this point in the history
  • Loading branch information
nada-deriv committed Jun 13, 2024
1 parent 3118de7 commit 74e3340
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/hooks/custom-hooks/useSendbird.ts
Original file line number Diff line number Diff line change
Expand Up @@ -273,15 +273,15 @@ const useSendbird = (orderId: string | undefined, isErrorOrderInfo: boolean, cha
useEffect(() => {
// if the user has not created a chat URL for the order yet, create one using p2p_create_chat endpoint
// chatChannelUrl is received from order details, hence check if chat url was already created using p2p_create_chat
if (orderId && !chatChannelUrl && !chatChannel?.url) {
if (!chatChannel?.url && sendbirdServiceToken?.app_id && orderId) {
initialiseChat();
} else if (orderId && !chatChannelUrl && !chatChannel?.url) {
createChat({
order_id: orderId,
});
} else if (!chatChannel?.url) {
initialiseChat();
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [orderId, chatChannelUrl, chatChannel?.url]);
}, [orderId, chatChannelUrl, chatChannel?.url, sendbirdServiceToken?.app_id]);

return {
activeChatChannel: chatChannel,
Expand Down

0 comments on commit 74e3340

Please sign in to comment.