diff --git a/.gitea/workflows/!-fix-bun-lock-file.yml b/.gitea/workflows/!-fix-bun-lock-file.yml deleted file mode 100644 index be427d5..0000000 --- a/.gitea/workflows/!-fix-bun-lock-file.yml +++ /dev/null @@ -1,29 +0,0 @@ -name: Fix bun lock file (Renovate) - -on: - workflow_dispatch: - push: - branches-ignore: - - master - paths: - - '**/package.json' # Detect changes in any package.json file in any directory - -jobs: - build: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - - name: Install bun - uses: oven-sh/setup-bun@v2 - - - name: Install dependencies - run: bun install - - - name: Commit bun lock file - run: | - git config --global user.email "helper@fascinated.cc" - git config --global user.name "Bun Fixer" - git add bun.lockb - git commit -m "Fix bun lock file" - git push \ No newline at end of file diff --git a/projects/common/src/types/player/impl/scoresaber-player.ts b/projects/common/src/types/player/impl/scoresaber-player.ts index fe04345..d6c8d61 100644 --- a/projects/common/src/types/player/impl/scoresaber-player.ts +++ b/projects/common/src/types/player/impl/scoresaber-player.ts @@ -4,6 +4,9 @@ import { PlayerHistory } from "../player-history"; import ScoreSaberPlayerToken from "../../token/scoresaber/score-saber-player-token"; import { formatDateMinimal, getDaysAgoDate, getMidnightAlignedDate } from "../../../utils/time-utils"; import { getPageFromRank } from "../../../utils/utils"; +import { getCookieValue } from "website/src/common/cookie-utils"; +import { db } from "website/src/common/database/database"; +import { isServer } from "@tanstack/react-query"; /** * A ScoreSaber player. @@ -76,12 +79,10 @@ export default interface ScoreSaberPlayer extends Player { * * @param token the player token * @param apiUrl the api url for SSR - * @param playerIdCookie the player id cookie (doesn't need to be set) */ export async function getScoreSaberPlayerFromToken( token: ScoreSaberPlayerToken, - apiUrl: string, - playerIdCookie?: string + apiUrl: string ): Promise { const bio: ScoreSaberBio = { lines: token.bio?.split("\n") || [], @@ -99,6 +100,8 @@ export async function getScoreSaberPlayerFromToken( let isBeingTracked = false; const todayDate = formatDateMinimal(getMidnightAlignedDate(new Date())); let statisticHistory: { [key: string]: PlayerHistory } = {}; + + const playerIdCookie = isServer ? await getCookieValue("playerId") : (await db.getSettings())?.playerId; try { const { statistics: history } = await ky .get<{ diff --git a/projects/website/src/app/(pages)/player/[...slug]/page.tsx b/projects/website/src/app/(pages)/player/[...slug]/page.tsx index 6a47a16..a3dd4a6 100644 --- a/projects/website/src/app/(pages)/player/[...slug]/page.tsx +++ b/projects/website/src/app/(pages)/player/[...slug]/page.tsx @@ -55,8 +55,7 @@ const getPlayerData = async ({ params }: Props, fetchScores: boolean = true): Pr } const playerToken = await scoresaberService.lookupPlayer(id); - const player = - playerToken && (await getScoreSaberPlayerFromToken(playerToken, config.siteApi, await getCookieValue("playerId"))); + const player = playerToken && (await getScoreSaberPlayerFromToken(playerToken, config.siteApi)); let scores: ScoreSaberPlayerScoresPageToken | undefined; if (fetchScores) { scores = await scoresaberService.lookupPlayerScores({ diff --git a/projects/website/src/components/api/api-health.tsx b/projects/website/src/components/api/api-health.tsx index 318eec0..c84bc92 100644 --- a/projects/website/src/components/api/api-health.tsx +++ b/projects/website/src/components/api/api-health.tsx @@ -16,7 +16,7 @@ export function ApiHealth() { useQuery({ queryKey: ["api-health"], queryFn: async () => { - const status = (await getApiHealth(config.siteApi)).online; + const status = (await getApiHealth(config.siteApi + "/health")).online; setOnline(status); return status; }, diff --git a/projects/website/src/components/player/player-data.tsx b/projects/website/src/components/player/player-data.tsx index f5cd453..f2b30d5 100644 --- a/projects/website/src/components/player/player-data.tsx +++ b/projects/website/src/components/player/player-data.tsx @@ -17,7 +17,6 @@ import { scoresaberService } from "@ssr/common/service/impl/scoresaber"; import { config } from "../../../config"; import useDatabase from "@/hooks/use-database"; import { useLiveQuery } from "dexie-react-hooks"; -import { getCookieValue } from "@/common/cookie-utils"; const REFRESH_INTERVAL = 1000 * 60 * 5; @@ -50,9 +49,8 @@ export default function PlayerData({ if (playerResponse == undefined) { return undefined; } - return await getScoreSaberPlayerFromToken(playerResponse, config.siteApi, await getCookieValue("playerId")); + return await getScoreSaberPlayerFromToken(playerResponse, config.siteApi); }, - staleTime: REFRESH_INTERVAL, refetchInterval: REFRESH_INTERVAL, refetchIntervalInBackground: false, });