From c82bf68cbebb57546703915dd6b7ab82fa882889 Mon Sep 17 00:00:00 2001 From: Alex Frantz Date: Sun, 21 Sep 2025 13:30:05 -0400 Subject: [PATCH] don't refresh when rerendering --- src/components/GameComponent.tsx | 9 +- src/components/modules/PictureCarousel.tsx | 43 +++++++++ src/pages/App.tsx | 100 +-------------------- 3 files changed, 50 insertions(+), 102 deletions(-) create mode 100644 src/components/modules/PictureCarousel.tsx diff --git a/src/components/GameComponent.tsx b/src/components/GameComponent.tsx index 7bdfa71..fb0ea54 100644 --- a/src/components/GameComponent.tsx +++ b/src/components/GameComponent.tsx @@ -14,6 +14,8 @@ export default function GameComponent() { const [game, setGame] = useState(null); useEffect(() => { + if (game) return; + async function fetchGame() { const response = await fetch( "https://api.alexav.gg/v4/tracker/latestGame" @@ -27,9 +29,6 @@ export default function GameComponent() { } } - setTimeout(() => { - fetchGame(); - }, 60000); fetchGame(); }, []); @@ -70,9 +69,9 @@ export default function GameComponent() { <>

previously played

- {game.history.splice(0, 5).map((v) => { + {game.history.splice(0, 5).map((v, k) => { return ( -
+

{v.game}

{dateOrTime(v)}

diff --git a/src/components/modules/PictureCarousel.tsx b/src/components/modules/PictureCarousel.tsx new file mode 100644 index 0000000..9945511 --- /dev/null +++ b/src/components/modules/PictureCarousel.tsx @@ -0,0 +1,43 @@ +import { useState } from "react"; +import Overlay from "../Overlay"; +import Picture from "../Picture"; + +const images = [ + "https://storage.alexav.gg/content/1f822215-0768-424d-893a-13bcd10aa98b.jpg", + "https://storage.alexav.gg/content/de890eaf-fc73-42a4-9fbe-a62313394a4c.jpg", + "https://storage.alexav.gg/content/d057af80-3d03-45ca-88b2-680c1e7c63c1.jpg", + "https://storage.alexav.gg/content/1d717aab-3058-405a-b04d-324d7ab3e658.jpg", + "https://storage.alexav.gg/content/2f36c1dd-eaf8-4fd3-a3cd-1d25fe8f5a07.jpg", +]; + +export default function PictureCarousel() { + const [selectedImage, setSelectedImage] = useState(""); + + return ( + <> + {selectedImage !== "" && ( + setSelectedImage("")}> + + + )} + +
+

pictures

+ +
+
+ {images.map((v, k) => { + return ( + setSelectedImage(v)} + /> + ); + })} +
+
+
+ + ); +} diff --git a/src/pages/App.tsx b/src/pages/App.tsx index d957f44..a92b471 100644 --- a/src/pages/App.tsx +++ b/src/pages/App.tsx @@ -3,115 +3,21 @@ import MusicComponent from "../components/MusicComponent"; import TVComponent from "../components/TVComponent"; import GameComponent from "../components/GameComponent"; import FantasyStatus from "../components/FantasyStatus"; -import Picture from "../components/Picture"; -import Overlay from "../components/Overlay"; -import { useState } from "react"; - -const images = [ - "https://storage.alexav.gg/content/1f822215-0768-424d-893a-13bcd10aa98b.jpg", - "https://storage.alexav.gg/content/de890eaf-fc73-42a4-9fbe-a62313394a4c.jpg", - "https://storage.alexav.gg/content/d057af80-3d03-45ca-88b2-680c1e7c63c1.jpg", - "https://storage.alexav.gg/content/1d717aab-3058-405a-b04d-324d7ab3e658.jpg", - "https://storage.alexav.gg/content/2f36c1dd-eaf8-4fd3-a3cd-1d25fe8f5a07.jpg", -]; -// const lyrics: LyricItem[] = [ -// { -// string: "and we're laying on the roof of my car", -// url: "https://open.spotify.com/track/4Pt2R2EJ3rZBRn2JpH7WnJ?si=7a167c7b22354d24", -// }, -// { -// string: "your funeral was beautiful", -// url: "https://open.spotify.com/track/4ZJ4vzLQekI0WntDbanNC7?si=914245f4e48a4c00", -// }, -// { -// string: "she was always the one", -// url: "https://open.spotify.com/track/21n769QrJtrmN0pXuBkYOm?si=b4a5e7f627b54fd9", -// }, -// { -// string: "how lucky are we?", -// url: "https://open.spotify.com/track/5iJKGpnFfvbjZJeAtwXfCj?si=a0b160c9cead4863", -// }, -// { -// string: "i'm yours to take darlin'", -// url: "https://open.spotify.com/track/2nATTe1i7aMzIZ8klEpgQ7?si=1bcd8e6aa9324b81", -// }, -// { -// string: "wet, hot, american nights", -// url: "https://open.spotify.com/track/3c9EsIo34kil8Oj1reaozB?si=8c0aaf0fdb7a4e5f", -// }, -// { -// string: "it ain't the whiskey that gets me", -// url: "https://open.spotify.com/track/0AsrOS8HktHe9TaB1i9W3v?si=c186a29f4e804d05", -// }, -// { -// string: "i wrote a song for you", -// url: "https://open.spotify.com/track/744zwLqGKbOZW3RnxkRfHE?si=4d2230964fcc4f2f", -// }, -// { -// string: "oh madeline, how you been?", -// url: "https://open.spotify.com/track/2DDo2QqElDO9PgOHeGtQiy?si=0fdcbaeb64694249", -// }, -// { -// string: "she makes this country boy feel like a king", -// url: "https://open.spotify.com/track/091Ibwvg7tTp7eNGLlT7cT?si=67be323416b24729", -// }, -// { -// string: "ain't in it for my health", -// url: "https://open.spotify.com/track/5Mz9T6QGwScq6Yt7DAXxi8?si=f51ff7f76dd24b00", -// }, -// ]; -// type LyricItem = { -// string: string; -// url: string; -// }; +import PictureCarousel from "../components/modules/PictureCarousel"; export default function App() { - const [selectedImage, setSelectedImage] = useState(""); - - // const [lyric, setLyric] = useState(); - // const getRandomLyric = () => { - // const randomNumber = Math.floor(Math.random() * lyrics.length); - // setLyric(lyrics[randomNumber]); - // }; - // useEffect(() => { - // getRandomLyric(); - // }, []); - return ( - {selectedImage !== "" && ( - setSelectedImage("")}> - - - )} -

welcome to my site !

-
-

pictures

- -
-
- {images.map((v, k) => { - return ( - setSelectedImage(v)} - /> - ); - })} -
-
-
- +
-
+

alex, 18