From 6dc107babf21e36edee42eda31bd194f7bb65f3b Mon Sep 17 00:00:00 2001
From: Sewmina
Date: Wed, 16 Apr 2025 03:39:52 +0000
Subject: [PATCH] snakes v1
---
src/components/GameHistory.tsx | 13 +++++++----
src/components/HeroSection.tsx | 41 +++++++++++++---------------------
src/components/OpenGames.tsx | 6 ++---
src/components/PrivyButton.tsx | 12 +++++-----
src/components/YourGames.tsx | 2 +-
src/data/shared.ts | 2 +-
6 files changed, 37 insertions(+), 39 deletions(-)
diff --git a/src/components/GameHistory.tsx b/src/components/GameHistory.tsx
index 86c0388..3bcbe86 100644
--- a/src/components/GameHistory.tsx
+++ b/src/components/GameHistory.tsx
@@ -4,6 +4,7 @@ import { Game } from "@/types/Game";
import { games } from "@/data/games";
import { WAGER_PRIZE_MULT } from "@/shared/constants";
import { EXPLORER_ADDRESS_TEMPLATE, API_URL } from "@/data/shared";
+import Image from 'next/image';
interface GameHistory {
address: string;
@@ -175,15 +176,19 @@ export default function GameHistoryModal({
{outcomeText}
-
-
{/* View TX Action */}
diff --git a/src/components/HeroSection.tsx b/src/components/HeroSection.tsx
index 923f7a6..66636da 100644
--- a/src/components/HeroSection.tsx
+++ b/src/components/HeroSection.tsx
@@ -28,32 +28,11 @@ export default function HeroSection() {
const { user } = usePrivy();
const iframeRef = useRef(null);
-
- useEffect(()=>{
- if(rematch){
- if(!lastActiveBet){
- console.log(`last active bet was null, heres active bet ${myActiveBet}`);
- }
- const isOwner = lastActiveBet?.owner_id == user?.id;
- console.log(`rematch function ${isOwner ? "owner" : "joiner"} owner_id:${lastActiveBet?.owner_id}`);
-
- if(isOwner){
- handleCreateRematch();
- }else{
- handleJoinRematch();
- }
- }
-
- },[rematch])
-
-
const game_close_signal = (status: number) => {
setRematch(status == 1);
setMyActiveBet(undefined);
};
-
-
const updateBets = async () => {
if(ready){
const wallet = wallets.find((_wallet) => _wallet.type === "solana") || wallets[0];
@@ -218,16 +197,28 @@ export default function HeroSection() {
}
};
-
+ useEffect(() => {
+ if(rematch){
+ if(true){
+ handleCreateRematch();
+ }else{
+ handleJoinRematch();
+ }
+ }
+ },[rematch, handleCreateRematch, handleJoinRematch]);
+
+ useEffect(() => {
+ if (ready) {
+ updateBets();
+ }
+ }, [ready, updateBets]);
useEffect(() => {
if (!ready) return;
-
updateBets();
const interval = setInterval(updateBets, 3000);
-
return () => clearInterval(interval);
- }, [ready]);
+ }, [ready, updateBets]);
useEffect(() => {
const handleMessage = (event: MessageEvent) => {
diff --git a/src/components/OpenGames.tsx b/src/components/OpenGames.tsx
index c54aebb..90df47e 100644
--- a/src/components/OpenGames.tsx
+++ b/src/components/OpenGames.tsx
@@ -97,7 +97,7 @@ export default function YourGames({ bets }: GameModalProps) {
updateBets();
const interval = setInterval(updateBets, 10000);
return () => clearInterval(interval);
- }, [bets]);
+ }, [bets, updateBets]);
return (
@@ -162,7 +162,7 @@ export default function YourGames({ bets }: GameModalProps) {
height={24}
className="rounded-full"
onError={(e) => {
- // @ts-ignore
+ //@ts-expect-error e.target has no src, but it needs to be changed
e.target.src = defaultPFP;
setFailedImages(prev => new Set(prev).add(ownerPFP));
}}
@@ -235,7 +235,7 @@ export default function YourGames({ bets }: GameModalProps) {
height={32}
className="w-8 h-8 rounded-full mr-2"
onError={(e) => {
- // @ts-ignore
+ //@ts-expect-error e.target has no src, but it needs to be changed
e.target.src = defaultPFP;
setFailedImages(prev => new Set(prev).add(modalOwnerPFP));
}}
diff --git a/src/components/PrivyButton.tsx b/src/components/PrivyButton.tsx
index 393b67a..5bf1d6a 100644
--- a/src/components/PrivyButton.tsx
+++ b/src/components/PrivyButton.tsx
@@ -370,10 +370,12 @@ export default function PrivyButton() {
{/* Avatar + Link Twitter Row */}
-

{(!user.twitter) ? (