;
} & GamePT) {
const { stats, leaderboard } = data;
@@ -97,8 +105,6 @@ function LeaderboardsPageContent({
// hack - we aren't returned from this api call for some reason.
userMap.set(reqUser.id, reqUser);
- const gptConfig = GetGamePTConfig(game, playtype);
-
const bestNearbyUser = stats.thisUsersRanking.ranking - stats.above.length;
function LeaderboardRow({ s, i }: { s: UserGameStats; i: integer }) {
@@ -125,7 +131,7 @@ function LeaderboardsPageContent({
{userMap.get(s.userID)?.username}
- | {(s.ratings[gptConfig.defaultProfileRatingAlg] ?? 0).toFixed(2)} |
+ {(s.ratings[alg] ?? 0).toFixed(2)} |
{/* temp */}
{Object.entries(s.classes).length
@@ -156,7 +162,7 @@ function LeaderboardsPageContent({
}
>
-
+
<>
{bestNearbyUser > 1 &&
leaderboard.gameStats
diff --git a/client/src/app/routes/UserRoutes.tsx b/client/src/app/routes/UserRoutes.tsx
index 57f7c8673..07d03b300 100644
--- a/client/src/app/routes/UserRoutes.tsx
+++ b/client/src/app/routes/UserRoutes.tsx
@@ -155,18 +155,8 @@ function UserGamePlaytypeRoutes({ reqUser, game }: { reqUser: PublicUserDocument
const { user } = useContext(UserContext);
const { setSettings } = useContext(UGPTSettingsContext);
- const { isLoading, error, data } = useQuery>(
- [reqUser.id, game, playtype],
- async () => {
- const res = await APIFetchV1(
- `/users/${reqUser.id}/games/${game}/${playtype}`
- );
-
- if (!res.success) {
- console.error(res);
- throw res;
- }
-
+ useEffect(() => {
+ (async () => {
if (user) {
const settingsRes = await APIFetchV1(
`/users/${user.id}/games/${game}/${playtype}/settings`
@@ -177,8 +167,28 @@ function UserGamePlaytypeRoutes({ reqUser, game }: { reqUser: PublicUserDocument
throw settingsRes;
}
+ console.log(settingsRes.body);
+
setSettings(settingsRes.body);
}
+ })();
+
+ return () => {
+ setSettings(null);
+ };
+ }, [user, game, playtype]);
+
+ const { isLoading, error, data } = useQuery>(
+ [reqUser.id, game, playtype],
+ async () => {
+ const res = await APIFetchV1(
+ `/users/${reqUser.id}/games/${game}/${playtype}`
+ );
+
+ if (!res.success) {
+ console.error(res);
+ throw res;
+ }
return res.body;
},
diff --git a/client/src/components/user/UGPTHeader.tsx b/client/src/components/user/UGPTHeader.tsx
index e5eea5391..3a262d5bd 100644
--- a/client/src/components/user/UGPTHeader.tsx
+++ b/client/src/components/user/UGPTHeader.tsx
@@ -21,6 +21,7 @@ import ProfileBadges from "./ProfileBadges";
import { GameClassSets } from "tachi-common/js/game-classes";
import UGPTRatingsTable from "./UGPTStatsOverview";
import RankingData from "./UGPTRankingData";
+import { useProfileRatingAlg } from "components/util/useScoreRatingAlg";
export function UGPTHeaderBody({
reqUser,
@@ -78,7 +79,7 @@ export function UGPTHeaderBody({
-
+
>
);
diff --git a/client/src/components/user/UGPTRankingData.tsx b/client/src/components/user/UGPTRankingData.tsx
index c901cd6bb..ef6645284 100644
--- a/client/src/components/user/UGPTRankingData.tsx
+++ b/client/src/components/user/UGPTRankingData.tsx
@@ -1,6 +1,48 @@
+import { useProfileRatingAlg } from "components/util/useScoreRatingAlg";
import React from "react";
+import { IDStrings, integer, UGSRatingsLookup } from "tachi-common";
+import { GamePT } from "types/react";
-export default function RankingData({ ranking, outOf }: { ranking: number; outOf: number }) {
+export default function RankingData({
+ rankingData,
+ game,
+ playtype,
+}: {
+ rankingData: Record;
+} & GamePT) {
+ const alg = useProfileRatingAlg(game, playtype);
+
+ const extendData = [];
+
+ for (const k in rankingData) {
+ const key = k as UGSRatingsLookup[IDStrings];
+
+ if (key !== alg) {
+ extendData.push(
+
+
+ {key}: #{rankingData[key].ranking}/{rankingData[key].outOf}
+
+
+ );
+ }
+ }
+
+ return (
+
+
+ Ranking{extendData.length ? ` (${alg})` : ""}
+
+
+ #{rankingData[alg].ranking}
+ /{rankingData[alg].outOf}
+
+ {extendData}
+
+ );
+}
+
+export function LazyRankingData({ ranking, outOf }: { ranking: integer; outOf: integer }) {
return (
diff --git a/client/src/components/util/useScoreRatingAlg.tsx b/client/src/components/util/useScoreRatingAlg.tsx
index 3de4bebe7..d74aad5e2 100644
--- a/client/src/components/util/useScoreRatingAlg.tsx
+++ b/client/src/components/util/useScoreRatingAlg.tsx
@@ -6,6 +6,7 @@ import {
IDStrings,
ScoreCalculatedDataLookup,
SessionCalculatedDataLookup,
+ UGSRatingsLookup,
} from "tachi-common";
import { Playtype } from "types/tachi";
@@ -38,3 +39,18 @@ export function useSessionRatingAlg(
return settings.preferences.preferredSessionAlg as SessionCalculatedDataLookup[I];
}
+
+export function useProfileRatingAlg(
+ game: Game,
+ playtype: Playtype
+): UGSRatingsLookup[I] {
+ const { settings } = useContext(UGPTSettingsContext);
+
+ if (!settings?.preferences.preferredProfileAlg) {
+ const gptConfig = GetGamePTConfig(game, playtype);
+
+ return gptConfig.defaultProfileRatingAlg as UGSRatingsLookup[I];
+ }
+
+ return settings.preferences.preferredProfileAlg as UGSRatingsLookup[I];
+}
diff --git a/client/src/types/api-returns.ts b/client/src/types/api-returns.ts
index d470136a0..59e6a92d0 100644
--- a/client/src/types/api-returns.ts
+++ b/client/src/types/api-returns.ts
@@ -13,7 +13,7 @@ import {
ChartDocument,
SongDocument,
PBScoreDocument,
- ShowcaseStatDetails,
+ UGSRatingsLookup,
} from "tachi-common";
export interface UGPTStatsReturn {
@@ -21,10 +21,13 @@ export interface UGPTStatsReturn {
firstScore: ScoreDocument;
mostRecentScore: ScoreDocument;
totalScores: number;
- rankingData: {
- ranking: integer;
- outOf: integer;
- };
+ rankingData: Record<
+ UGSRatingsLookup[I],
+ {
+ ranking: integer;
+ outOf: integer;
+ }
+ >;
}
export interface UGPTLeaderboardAdjacent {
|