diff --git a/packages/website/src/components/PlaylistOrder.tsx b/packages/website/src/components/PlaylistOrder.tsx index d90448881..d608e065c 100644 --- a/packages/website/src/components/PlaylistOrder.tsx +++ b/packages/website/src/components/PlaylistOrder.tsx @@ -1,11 +1,9 @@ import { Box, Flex } from "@radix-ui/themes"; -import { useLocale } from "../hooks/useLocale"; import { CurrentlyPlaying } from "./CurrentlyPlaying"; import { PlaylistActions } from "./PlaylistActions"; import { PlaylistTable } from "./PlaylistTable"; export function PlaylistOrder() { - return ( ( + ({ tank, checked, last, battles, index }) => { + const { locale, strings } = useLocale(); + const rtf = new Intl.RelativeTimeFormat(locale, { numeric: "auto" }); + const nowDays = Date.now() / (1000 * 60 * 60 * 24); + const lastDays = last ? last / (60 * 60 * 24) : undefined; - return ( - - {index + 1} + return ( + + {index + 1} - + - - {lastDays - ? rtf.format(Math.floor(lastDays - nowDays), "day") - : strings.website.tools.playlist.table.never} - + + {lastDays + ? rtf.format(Math.floor(lastDays - nowDays), "day") + : strings.website.tools.playlist.table.never} + - {battles} + {battles} - { - Playlist.mutate((draft) => { - draft.list![index].checked = !checked; - }); - }} - > - - - - - { Playlist.mutate((draft) => { - draft.list!.splice(index, 1); + draft.list![index].checked = !checked; }); }} > - - - - - ); -} + + + + + { + Playlist.mutate((draft) => { + draft.list!.splice(index, 1); + }); + }} + > + + + + + ); + }, + (a, b) => + a.checked === b.checked && + a.battles === b.battles && + a.last === b.last && + a.wins === b.wins && + a.index === b.index +); diff --git a/packages/website/src/pages/[...locale]/playlist/_index.tsx b/packages/website/src/pages/[...locale]/playlist/_index.tsx index 806f01bd6..985f63a2f 100644 --- a/packages/website/src/pages/[...locale]/playlist/_index.tsx +++ b/packages/website/src/pages/[...locale]/playlist/_index.tsx @@ -16,7 +16,7 @@ export function Page({ locale, skeleton, }: Props & MaybeSkeletonComponentProps) { - const list = Playlist.use((state) => state.list); + const generated = Playlist.use((state) => state.list !== undefined); const wargaming = App.use((state) => state.logins.wargaming); useEffect(() => { @@ -30,8 +30,8 @@ export function Page({ return ( - {!list && } - {list && } + {!generated && } + {generated && } );