logs
This commit is contained in:
@@ -47,11 +47,23 @@ export default function ChallengeDetail() {
|
||||
if (!socket) return;
|
||||
|
||||
const handlePredictionCreated = (prediction) => {
|
||||
setPredictions(prev => [prediction, ...prev]);
|
||||
toast.success(`New prediction from ${prediction.username}`);
|
||||
console.log('📥 Received prediction:created event', prediction);
|
||||
setPredictions(prev => {
|
||||
// Avoid duplicates
|
||||
if (prev.some(p => p.id === prediction.id)) {
|
||||
return prev;
|
||||
}
|
||||
return [prediction, ...prev];
|
||||
});
|
||||
|
||||
// Don't show toast for your own predictions
|
||||
if (prediction.user_id !== user.id) {
|
||||
toast.success(`New prediction from ${prediction.username}`);
|
||||
}
|
||||
};
|
||||
|
||||
const handlePredictionValidated = (prediction) => {
|
||||
console.log('📥 Received prediction:validated event', prediction);
|
||||
setPredictions(prev =>
|
||||
prev.map(p => p.id === prediction.id ? prediction : p)
|
||||
);
|
||||
@@ -63,10 +75,13 @@ export default function ChallengeDetail() {
|
||||
? '🎉 Your prediction was validated!'
|
||||
: '❌ Your prediction was invalidated'
|
||||
);
|
||||
} else {
|
||||
toast(`${prediction.username}'s prediction ${prediction.status}`);
|
||||
}
|
||||
};
|
||||
|
||||
const handleInvitationResponse = (response) => {
|
||||
console.log('📥 Received invitation response', response);
|
||||
if (response.status === 'accepted') {
|
||||
toast.success(`${response.username} joined the challenge!`);
|
||||
loadChallenge(); // Refresh participant list
|
||||
@@ -82,7 +97,7 @@ export default function ChallengeDetail() {
|
||||
socket.off('prediction:validated', handlePredictionValidated);
|
||||
socket.off('challenge:invitation_response', handleInvitationResponse);
|
||||
};
|
||||
}, [socket, user]);
|
||||
}, [socket, user.id, loadLeaderboard, loadChallenge]);
|
||||
|
||||
const loadChallenge = async () => {
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user