row_id int64 0 37.6k | type stringclasses 13 values | text stringlengths 1 5.72M ⌀ |
|---|---|---|
331 | content | null |
332 | content | null |
333 | content | null |
334 | content | import { getGuesses, Guess, handleGuessAndPotentialWinner } from "@/services/channel"; |
335 | content | isDisabled={updateGuessMutation.isPending || hasWinner} |
336 | content | isDisabled={updateGuessMutation.isPending || hasWinner} |
337 | content | {hasWinner && (\n <Box className="bg-success-50 border border-success-200 rounded-xl p-4 mb-4">\n <Text className="text-success-700 text-center font-medium">\n 🎉 We have a winner! No more guesses can be approved.\n </Text>\n </Box>\n )}\n |
338 | content | // Don't allow any changes if there's already a winner\n if (hasWinner) return;\n \n |
339 | content | .on('postgres_changes', {\n event: 'UPDATE',\n schema: 'public',\n table: 'challenges',\n filter: `id=eq.${challenge_id}`\n }, (payload) => {\n // Invalidate challenge query when challenge is updated (e.g., winner is set)\n queryClient.invalidateQueries({ queryKey: ['challenge', challenge_id] });\n })\n |
340 | content | // Enhanced realtime subscription to handle all guess changes (INSERT and UPDATE) and challenge updates |
341 | content | queryClient.invalidateQueries({ queryKey: ['challenge', challenge_id] });\n |
342 | content | // Get challenge information to check if there's already a winner\n const { data: challenge, isLoading: challengeLoading } = useQuery({\n queryKey: ['challenge', challenge_id],\n queryFn: () => getChallenge(challenge_id),\n });\n\n const hasWinner = !!challenge?.winner;\n\n |
343 | content | import { getGuesses, Guess, handleGuessAndPotentialWinner, getChallenge } from "@/services/channel"; |
344 | tab | null |
345 | selection_command | null |
346 | tab | null |
347 | selection_command | null |
348 | tab | null |
349 | selection_command | null |
350 | tab | null |
351 | tab | null |
352 | tab | null |
353 | selection_mouse | null |
354 | selection_command | null |
355 | tab | null |
356 | tab | null |
357 | tab | null |
358 | selection_mouse | null |
359 | tab | null |
360 | selection_command | null |
361 | selection_mouse | null |
362 | selection_command | null |
363 | selection_mouse | null |
364 | selection_command | null |
365 | selection_mouse | null |
366 | tab | null |
367 | selection_command | null |
368 | selection_mouse | null |
369 | selection_command | null |
370 | content | \n |
371 | content | c |
372 | selection_keyboard | null |
373 | content | o |
374 | selection_keyboard | null |
375 | content | n |
376 | selection_keyboard | null |
377 | content | null |
378 | content | null |
379 | content | null |
380 | content | null |
381 | content | c |
382 | selection_keyboard | null |
383 | content | o |
384 | selection_keyboard | null |
385 | content | n |
386 | selection_keyboard | null |
387 | content | s |
388 | selection_keyboard | null |
389 | content | ole.log('data', data); |
390 | selection_command | null |
391 | selection_command | null |
392 | selection_command | null |
393 | selection_command | null |
394 | selection_command | null |
395 | content | null |
396 | content | guess created |
397 | content | : |
398 | selection_keyboard | null |
399 | content | |
400 | selection_keyboard | null |
401 | selection_command | null |
402 | selection_mouse | null |
403 | selection_command | null |
404 | selection_mouse | null |
405 | selection_mouse | null |
406 | selection_mouse | null |
407 | selection_mouse | null |
408 | selection_mouse | null |
409 | selection_command | null |
410 | selection_mouse | null |
411 | selection_command | null |
412 | selection_mouse | null |
413 | selection_command | null |
414 | selection_mouse | ; |
415 | selection_command | null |
416 | selection_mouse | return data;\n}; |
417 | selection_mouse | }\n if (error) throw error;\n return data;\n}; |
418 | selection_mouse | }\n if (error) throw error;\n return data;\n}; |
419 | selection_mouse | if (channelError) throw channelError;\n }\n if (error) throw error;\n return data;\n}; |
420 | selection_mouse | .eq('id', data.channel_id);\n if (channelError) throw channelError;\n }\n if (error) throw error;\n return data;\n}; |
421 | selection_mouse | .from('channels')\n .update({ current_turn: nextTurn })\n .eq('id', data.channel_id);\n if (channelError) throw channelError;\n }\n if (error) throw error;\n return data;\n}; |
422 | selection_mouse | const { error: channelError } = await supabase\n .from('channels')\n .update({ current_turn: nextTurn })\n .eq('id', data.channel_id);\n if (channelError) throw channelError;\n }\n if (error) throw error;\n return data;\n}; |
423 | selection_mouse | if (challengeError) throw challengeError;\n const nextTurn = await getNextTurnRandomly(data.channel_id);\n const { error: channelError } = await supabase\n .from('channels')\n .update({ current_turn: nextTurn })\n .eq('id', data.channel_id);\n if (channelError) throw channelError;\n }\n if (error) throw error;\n return data;\n}; |
424 | selection_mouse | .single();\n if (challengeError) throw challengeError;\n const nextTurn = await getNextTurnRandomly(data.channel_id);\n const { error: channelError } = await supabase\n .from('channels')\n .update({ current_turn: nextTurn })\n .eq('id', data.channel_id);\n if (channelError) throw channelError;\n }\n if (error) throw error;\n return data;\n}; |
425 | selection_mouse | .select()\n .single();\n if (challengeError) throw challengeError;\n const nextTurn = await getNextTurnRandomly(data.channel_id);\n const { error: channelError } = await supabase\n .from('channels')\n .update({ current_turn: nextTurn })\n .eq('id', data.channel_id);\n if (channelError) throw channelError;\n }\n if (error) throw error;\n return data;\n}; |
426 | selection_mouse | .update({ winner: data.sender_id })\n .eq('id', data.challenge_id)\n .select()\n .single();\n if (challengeError) throw challengeError;\n const nextTurn = await getNextTurnRandomly(data.channel_id);\n const { error: channelError } = await supabase\n .from('channels')\n .update({ current_turn: nextTurn })\n .eq('id', data.channel_id);\n if (channelError) throw channelError;\n }\n if (error) throw error;\n return data;\n}; |
427 | selection_mouse | const { data: challenge, error: challengeError } = await supabase\n .from('challenges')\n .update({ winner: data.sender_id })\n .eq('id', data.challenge_id)\n .select()\n .single();\n if (challengeError) throw challengeError;\n const nextTurn = await getNextTurnRandomly(data.channel_id);\n const { error: channelError } = await supabase\n .from('channels')\n .update({ current_turn: nextTurn })\n .eq('id', data.channel_id);\n if (channelError) throw channelError;\n }\n if (error) throw error;\n return data;\n}; |
428 | selection_mouse | if (decision === true) {\n const { data: challenge, error: challengeError } = await supabase\n .from('challenges')\n .update({ winner: data.sender_id })\n .eq('id', data.challenge_id)\n .select()\n .single();\n if (challengeError) throw challengeError;\n const nextTurn = await getNextTurnRandomly(data.channel_id);\n const { error: channelError } = await supabase\n .from('channels')\n .update({ current_turn: nextTurn })\n .eq('id', data.channel_id);\n if (channelError) throw channelError;\n }\n if (error) throw error;\n return data;\n}; |
429 | selection_mouse | // If the guess is correct, update the challenge to set the winner and change turn to the next participant (randomly select from participants)\n if (decision === true) {\n const { data: challenge, error: challengeError } = await supabase\n .from('challenges')\n .update({ winner: data.sender_id })\n .eq('id', data.challenge_id)\n .select()\n .single();\n if (challengeError) throw challengeError;\n const nextTurn = await getNextTurnRandomly(data.channel_id);\n const { error: channelError } = await supabase\n .from('channels')\n .update({ current_turn: nextTurn })\n .eq('id', data.channel_id);\n if (channelError) throw channelError;\n }\n if (error) throw error;\n return data;\n}; |
430 | selection_mouse | \n // If the guess is correct, update the challenge to set the winner and change turn to the next participant (randomly select from participants)\n if (decision === true) {\n const { data: challenge, error: challengeError } = await supabase\n .from('challenges')\n .update({ winner: data.sender_id })\n .eq('id', data.challenge_id)\n .select()\n .single();\n if (challengeError) throw challengeError;\n const nextTurn = await getNextTurnRandomly(data.channel_id);\n const { error: channelError } = await supabase\n .from('channels')\n .update({ current_turn: nextTurn })\n .eq('id', data.channel_id);\n if (channelError) throw channelError;\n }\n if (error) throw error;\n return data;\n}; |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.