add default score sort (last selected)
All checks were successful
Deploy Website / deploy (push) Successful in 5m1s
All checks were successful
Deploy Website / deploy (push) Successful in 5m1s
This commit is contained in:
@ -2,12 +2,12 @@
|
||||
|
||||
import { CheckIcon } from "@heroicons/react/24/solid";
|
||||
import { useLiveQuery } from "dexie-react-hooks";
|
||||
import { setPlayerIdCookie } from "@/common/website-utils";
|
||||
import useDatabase from "../../hooks/use-database";
|
||||
import { useToast } from "@/hooks/use-toast";
|
||||
import Tooltip from "../tooltip";
|
||||
import { Button } from "../ui/button";
|
||||
import { revalidatePath } from "next/cache";
|
||||
import { setCookieValue } from "@/common/cookie-utils";
|
||||
|
||||
type Props = {
|
||||
/**
|
||||
@ -28,7 +28,7 @@ export default function ClaimProfile({ playerId }: Props) {
|
||||
const settings = await database.getSettings();
|
||||
|
||||
settings?.setPlayerId(playerId);
|
||||
setPlayerIdCookie(playerId);
|
||||
await setCookieValue("playerId", playerId);
|
||||
toast({
|
||||
title: "Profile Claimed",
|
||||
description: "You have claimed this profile.",
|
||||
|
@ -15,9 +15,9 @@ import ScoreSaberPlayerScoresPageToken from "@ssr/common/types/token/scoresaber/
|
||||
import { ScoreSort } from "@ssr/common/types/score/score-sort";
|
||||
import { scoresaberService } from "@ssr/common/service/impl/scoresaber";
|
||||
import { config } from "../../../config";
|
||||
import { getPlayerIdCookie } from "@/common/website-utils";
|
||||
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,7 +50,7 @@ export default function PlayerData({
|
||||
if (playerResponse == undefined) {
|
||||
return undefined;
|
||||
}
|
||||
return await getScoreSaberPlayerFromToken(playerResponse, config.siteApi, getPlayerIdCookie());
|
||||
return await getScoreSaberPlayerFromToken(playerResponse, config.siteApi, await getCookieValue("playerId"));
|
||||
},
|
||||
staleTime: REFRESH_INTERVAL,
|
||||
refetchInterval: REFRESH_INTERVAL,
|
||||
|
@ -16,6 +16,7 @@ import ScoreSaberPlayer from "@ssr/common/types/player/impl/scoresaber-player";
|
||||
import ScoreSaberPlayerScoresPageToken from "@ssr/common/types/token/scoresaber/score-saber-player-scores-page-token";
|
||||
import { ScoreSort } from "@ssr/common/types/score/score-sort";
|
||||
import { scoresaberService } from "@ssr/common/service/impl/scoresaber";
|
||||
import { setCookieValue } from "@/common/cookie-utils";
|
||||
|
||||
type Props = {
|
||||
initialScoreData?: ScoreSaberPlayerScoresPageToken;
|
||||
@ -88,10 +89,11 @@ export default function PlayerScores({ initialScoreData, initialSearch, player,
|
||||
*
|
||||
* @param newSort the new sort
|
||||
*/
|
||||
const handleSortChange = (newSort: ScoreSort) => {
|
||||
const handleSortChange = async (newSort: ScoreSort) => {
|
||||
if (newSort !== pageState.sort) {
|
||||
setPageState({ page: 1, sort: newSort });
|
||||
setShouldFetch(true); // Set to true to trigger fetch
|
||||
await setCookieValue("lastScoreSort", newSort); // Set the default score sort
|
||||
}
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user