mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-24 20:19:49 +02:00
fix: session
This commit is contained in:
1 parent
c92d355484
commit
650dbf66a9
1 file changed
+14
-12
@@ -36,7 +36,6 @@ import {
|
|||||||
} from '@radix-ui/themes';
|
} from '@radix-ui/themes';
|
||||||
import { debounce } from 'lodash-es';
|
import { debounce } from 'lodash-es';
|
||||||
import { useEffect, useMemo, useRef, useState } from 'react';
|
import { useEffect, useMemo, useRef, useState } from 'react';
|
||||||
import usePromise from 'react-promise-suspense';
|
|
||||||
import { PageWrapper } from '../../../components/PageWrapper';
|
import { PageWrapper } from '../../../components/PageWrapper';
|
||||||
import { TankRowHeaderCell } from '../../../components/TankRowHeaderCell';
|
import { TankRowHeaderCell } from '../../../components/TankRowHeaderCell';
|
||||||
import { Session, type SessionTracking } from '../../../stores/session';
|
import { Session, type SessionTracking } from '../../../stores/session';
|
||||||
@@ -64,17 +63,20 @@ function Content() {
|
|||||||
const [tankStatsB, setTankStatsB] = useState<IndividualTankStats[] | null>(
|
const [tankStatsB, setTankStatsB] = useState<IndividualTankStats[] | null>(
|
||||||
null,
|
null,
|
||||||
);
|
);
|
||||||
const accountInfo = usePromise(
|
const [accountInfo, setAccountInfo] = useState<
|
||||||
(id?: number) =>
|
IndividualAccountInfo | null | undefined
|
||||||
new Promise<IndividualAccountInfo | null>(async (resolve) => {
|
>(undefined);
|
||||||
if (!id) return resolve(null);
|
|
||||||
|
|
||||||
resolve(
|
useEffect(() => {
|
||||||
session.tracking ? await getAccountInfo(idToRegion(id), id) : null,
|
(async () => {
|
||||||
);
|
const id = session.tracking ? session.player.id : undefined;
|
||||||
}),
|
if (!id) return setAccountInfo(null);
|
||||||
[session.tracking ? session.player.id : undefined],
|
|
||||||
);
|
setAccountInfo(
|
||||||
|
session.tracking ? await getAccountInfo(idToRegion(id), id) : null,
|
||||||
|
);
|
||||||
|
})();
|
||||||
|
}, [session.tracking && session.player.id]);
|
||||||
const delta = useMemo(
|
const delta = useMemo(
|
||||||
() =>
|
() =>
|
||||||
session.tracking && tankStatsB
|
session.tracking && tankStatsB
|
||||||
@@ -83,7 +85,7 @@ function Content() {
|
|||||||
.map((entry) => {
|
.map((entry) => {
|
||||||
const tank = tankDefinitions.tanks[entry.tank_id];
|
const tank = tankDefinitions.tanks[entry.tank_id];
|
||||||
const average = tankAverages.averages[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);
|
const statsPretty = prettifyStats(stats);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|||||||
Reference in new issue
Block a user