diff --git a/client/package.json b/client/package.json
index b7bbe80f5..a5d02e6e1 100644
--- a/client/package.json
+++ b/client/package.json
@@ -74,7 +74,7 @@
"resolve": "1.12.0",
"resolve-url-loader": "3.1.0",
"socicon": "3.0.5",
- "tachi-common": "0.1.42"
+ "tachi-common": "0.2.4"
},
"devDependencies": {
"@types/humanize-duration": "3.25.1",
diff --git a/client/pnpm-lock.yaml b/client/pnpm-lock.yaml
index b3370eb8e..8d8be6fb4 100644
--- a/client/pnpm-lock.yaml
+++ b/client/pnpm-lock.yaml
@@ -76,7 +76,7 @@ specifiers:
serve: 11.2.0
socicon: 3.0.5
style-loader: 1.0.0
- tachi-common: 0.1.42
+ tachi-common: 0.2.4
terser-webpack-plugin: 1.4.1
ts-pnp: 1.1.4
typescript: 4.3.5
@@ -140,7 +140,7 @@ dependencies:
resolve: 1.12.0
resolve-url-loader: 3.1.0
socicon: 3.0.5
- tachi-common: 0.1.42_typescript@4.3.5
+ tachi-common: 0.2.4_typescript@4.3.5
devDependencies:
'@types/humanize-duration': 3.25.1
@@ -11760,8 +11760,8 @@ packages:
strip-ansi: 6.0.0
dev: true
- /tachi-common/0.1.42_typescript@4.3.5:
- resolution: {integrity: sha512-3rNfFXObf9eO6Rf/B/IncQ441bQXfCZvmZgsWYXyVl8GjtGH03/wblGp2stCHRXnau+l5n/k7SUn1G9hw516WA==}
+ /tachi-common/0.2.4_typescript@4.3.5:
+ resolution: {integrity: sha512-5Q6c0qGhQyPKKiCg+BvuYbt9k5q/B1c3aBNR3KaX+aEKSQ8ZbuYTcKPKnQlDccjDfcGNj2OAmELx3oHz4UJdGA==}
dependencies:
monk: 7.3.4
tap: 15.0.9_typescript@4.3.5
diff --git a/client/src/app/pages/dashboard/users/UserGamesPage.tsx b/client/src/app/pages/dashboard/users/UserGamesPage.tsx
index a8c49e02e..a69c1763d 100644
--- a/client/src/app/pages/dashboard/users/UserGamesPage.tsx
+++ b/client/src/app/pages/dashboard/users/UserGamesPage.tsx
@@ -96,7 +96,7 @@ function GameStatContainer({ ugs, reqUser }: { ugs: UGSWithRankingData } & Props
header={FormatGame(ugs.game, ugs.playtype)}
>
-
+
);
}
diff --git a/client/src/app/pages/dashboard/users/games/_game/_playtype/SessionsPage.tsx b/client/src/app/pages/dashboard/users/games/_game/_playtype/SessionsPage.tsx
index b30a59098..c20722942 100644
--- a/client/src/app/pages/dashboard/users/games/_game/_playtype/SessionsPage.tsx
+++ b/client/src/app/pages/dashboard/users/games/_game/_playtype/SessionsPage.tsx
@@ -17,6 +17,8 @@ import { GamePT } from "types/react";
import { APIFetchV1 } from "util/api";
import SelectButton from "components/util/SelectButton";
import Icon from "components/util/Icon";
+import { useSessionRatingAlg } from "components/util/useScoreRatingAlg";
+import { NumericSOV } from "util/sorts";
export default function SessionsPage({
reqUser,
@@ -38,6 +40,8 @@ export default function SessionsPage({
const baseUrl = `/users/${reqUser.id}/games/${game}/${playtype}/sessions`;
+ const rating = useSessionRatingAlg(game, playtype);
+
const { isLoading, error, data } = useQuery(
`${baseUrl}/${sessionSet}`,
async () => {
@@ -47,12 +51,14 @@ export default function SessionsPage({
throw res;
}
- return res.body.map((e, i) => ({
- ...e,
- __related: {
- index: i,
- },
- }));
+ return res.body
+ .sort(NumericSOV(x => x.calculatedData[rating] ?? 0, true))
+ .map((e, i) => ({
+ ...e,
+ __related: {
+ index: i,
+ },
+ }));
}
);
diff --git a/client/src/types/api-returns.ts b/client/src/types/api-returns.ts
index 59e6a92d0..28f68a5d6 100644
--- a/client/src/types/api-returns.ts
+++ b/client/src/types/api-returns.ts
@@ -86,7 +86,7 @@ export interface SpecificSessionReturns {
}
export type UGSWithRankingData = UserGameStats & {
- __rankingData: { outOf: number; ranking: number };
+ __rankingData: Record;
};
export interface SongChartsSearch {
diff --git a/client/src/util/sorts.ts b/client/src/util/sorts.ts
index 97b5b5b1f..0564aca6b 100644
--- a/client/src/util/sorts.ts
+++ b/client/src/util/sorts.ts
@@ -16,7 +16,10 @@ export function PropSort(...props: string[]) {
* Sorts On Value numerically.
* @returns A sorting function
*/
-export function NumericSOV(getValueFn: (data: T) => number) {
+export function NumericSOV(getValueFn: (data: T) => number, reverse = false) {
+ if (reverse) {
+ return (a: T, b: T) => getValueFn(b) - getValueFn(a);
+ }
return (a: T, b: T) => getValueFn(a) - getValueFn(b);
}