From cef63dee14dcf0a2eb5df2f12db398142fb913c2 Mon Sep 17 00:00:00 2001 From: Grant Date: Fri, 19 Jul 2024 10:29:10 -0600 Subject: [PATCH] update event info details to reflect event end --- .../src/components/EventInfoOverlay.tsx | 49 +------------------ .../client/src/components/Toolbar/Palette.tsx | 9 +++- 2 files changed, 8 insertions(+), 50 deletions(-) diff --git a/packages/client/src/components/EventInfoOverlay.tsx b/packages/client/src/components/EventInfoOverlay.tsx index 6ca75ee..b6444ce 100644 --- a/packages/client/src/components/EventInfoOverlay.tsx +++ b/packages/client/src/components/EventInfoOverlay.tsx @@ -2,8 +2,6 @@ import React, { useEffect, useRef } from "react"; import { useAppContext } from "../contexts/AppContext"; import { Button } from "@nextui-org/react"; -const EVENT_START = 1720756800000; // midnight 7/12/2024 eastern - /** * *oh god the terrible code* * @@ -15,51 +13,6 @@ const EVENT_START = 1720756800000; // midnight 7/12/2024 eastern */ export const EventInfoOverlay = ({ children }: React.PropsWithChildren) => { const { setInfoSidebar, setSettingsSidebar } = useAppContext(); - const $countdown = useRef(null); - - const getCountdown = () => { - // date math always confuses me... - // https://stackoverflow.com/a/7709819 - - const now = Date.now(); - const ms = EVENT_START - now; - const days = Math.floor(ms / (1000 * 60 * 60 * 24)); - const hours = Math.floor((ms % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60)); - const minutes = Math.floor( - ((ms % (1000 * 60 * 60 * 24)) % (1000 * 60 * 60)) / (1000 * 60) - ); - const seconds = Math.round( - (((ms % (1000 * 60 * 60 * 24)) % (1000 * 60 * 60)) % (1000 * 60)) / 1000 - ); - - return [days, hours, minutes, seconds]; - }; - - const updateTime = () => { - if (!$countdown.current) return; - - const [days, hours, minutes, seconds] = getCountdown(); - - $countdown.current.innerText = [ - days && days + "d", - hours && hours + "h", - minutes && minutes + "m", - seconds && seconds + "s", - ] - .filter((a) => a) - .join(" "); - - $countdown.current.title = `${days} days ${hours} hours ${minutes} minutes ${seconds} seconds`; - }; - - useEffect(() => { - var interval = setInterval(updateTime, 1000); - updateTime(); - - return () => { - clearInterval(interval); - }; - }, []); return (
{ >

Canvas 2024

-

($countdown.current = r)} className="text-3xl">

+

Ended July 16th @ 4am UTC

diff --git a/packages/client/src/components/Toolbar/Palette.tsx b/packages/client/src/components/Toolbar/Palette.tsx index b3f9a3a..142983c 100644 --- a/packages/client/src/components/Toolbar/Palette.tsx +++ b/packages/client/src/components/Toolbar/Palette.tsx @@ -69,11 +69,16 @@ export const Palette = () => { {!user && (
{import.meta.env.VITE_INCLUDE_EVENT_INFO ? ( - <>The event hasn't started yet + <>The event has ended ) : (
You are not logged in -