From 650dbf66a9616d50abdf74731276471bca8e7e7e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tr=C3=A8sAbhi?= <43380238+tresabhi@users.noreply.github.com> Date: Mon, 21 Oct 2024 10:49:06 -0500 Subject: [PATCH] fix: session --- .../src/pages/tools/session/_index.tsx | 28 ++++++++++--------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/packages/website/src/pages/tools/session/_index.tsx b/packages/website/src/pages/tools/session/_index.tsx index cc88bb8e..2c4657bb 100644 --- a/packages/website/src/pages/tools/session/_index.tsx +++ b/packages/website/src/pages/tools/session/_index.tsx @@ -36,7 +36,6 @@ import { } from '@radix-ui/themes'; import { debounce } from 'lodash-es'; import { useEffect, useMemo, useRef, useState } from 'react'; -import usePromise from 'react-promise-suspense'; import { PageWrapper } from '../../../components/PageWrapper'; import { TankRowHeaderCell } from '../../../components/TankRowHeaderCell'; import { Session, type SessionTracking } from '../../../stores/session'; @@ -64,17 +63,20 @@ function Content() { const [tankStatsB, setTankStatsB] = useState( null, ); - const accountInfo = usePromise( - (id?: number) => - new Promise(async (resolve) => { - if (!id) return resolve(null); - - resolve( - session.tracking ? await getAccountInfo(idToRegion(id), id) : null, - ); - }), - [session.tracking ? session.player.id : undefined], - ); + const [accountInfo, setAccountInfo] = useState< + IndividualAccountInfo | null | undefined + >(undefined); + + useEffect(() => { + (async () => { + const id = session.tracking ? session.player.id : undefined; + if (!id) return setAccountInfo(null); + + setAccountInfo( + session.tracking ? await getAccountInfo(idToRegion(id), id) : null, + ); + })(); + }, [session.tracking && session.player.id]); const delta = useMemo( () => session.tracking && tankStatsB @@ -83,7 +85,7 @@ function Content() { .map((entry) => { const tank = tankDefinitions.tanks[entry.tank_id]; const average = tankAverages.averages[tank.id]; - const stats = generateStats(entry.all, average.mu); + const stats = generateStats(entry.all, average?.mu); const statsPretty = prettifyStats(stats); return {