Skip to content

Commit

Permalink
fix staging issue
Browse files Browse the repository at this point in the history
  • Loading branch information
GayChin committed Apr 17, 2024
1 parent 8aab971 commit f7ac2e1
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions app/matches/chatroom/chatroom.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { useSearchParams } from 'next/navigation';
import { GoReport } from 'react-icons/go';
import ReportModal from './report-modal';
import ChatroomVouchertModal from './chatroom-voucher-modal';
import { FaCropSimple } from 'react-icons/fa6';

const Chatroom = () => {
// Redux store
Expand Down Expand Up @@ -198,9 +199,11 @@ const Chatroom = () => {
console.log('Sending mark as read : ' + messageId);
stompClient.send('/app/message-read', {}, JSON.stringify(messagePayload));
await markMessageAsRead(messageId);
} else {
console.log("Stomp client for read doesn't exist");
return true;
}

console.log("Stomp client for read doesn't exist");
return false;
};

useEffect(() => {
Expand All @@ -213,7 +216,7 @@ const Chatroom = () => {
// Define a callback function to handle intersection changes
let intersectionCallback = (entries: any) => {
console.log('entries length : ', entries.length);
entries.forEach((entry: any) => {
entries.forEach(async (entry: any) => {
if (entry.isIntersecting) {
// When any message inside the container enters the viewport
const messageId = entry.target.getAttribute('data-message-id');
Expand All @@ -226,8 +229,14 @@ const Chatroom = () => {
senderProfileId === receiverProfileId &&
isMessageRead === 'N'
) {
handleMessageRead(parseInt(messageId), parseInt(senderProfileId));
entry.target.setAttribute('is-message-read', 'Y');
const isMessageRead = await handleMessageRead(
parseInt(messageId),
parseInt(senderProfileId)
);
console.log('is message read : ' + isMessageRead);
if (isMessageRead) {
entry.target.setAttribute('is-message-read', 'Y');
}
}
}
});
Expand Down

0 comments on commit f7ac2e1

Please sign in to comment.