optimize mini ranking to only update when they are visible
Some checks failed
Deploy / deploy (push) Failing after 2m21s

This commit is contained in:
Lee
2024-10-01 14:46:44 +01:00
parent 50d5c0e5bc
commit f30a373120
3 changed files with 49 additions and 4 deletions

View File

@ -15,8 +15,20 @@ import { PlayerRankingSkeleton } from "@/components/ranking/player-ranking-skele
const PLAYER_NAME_MAX_LENGTH = 18;
type MiniProps = {
/**
* The type of ranking to display.
*/
type: "Global" | "Country";
/**
* The player on this profile.
*/
player: ScoreSaberPlayer;
/**
* Whether the data should be updated
*/
shouldUpdate?: boolean;
};
type Variants = {
@ -53,7 +65,11 @@ const miniVariants: Variants = {
},
};
export default function Mini({ type, player }: MiniProps) {
export default function Mini({ type, player, shouldUpdate }: MiniProps) {
if (shouldUpdate == undefined) {
// Default to true
shouldUpdate = true;
}
const variant = miniVariants[type];
const icon = variant.icon(player);
@ -88,6 +104,7 @@ export default function Mini({ type, player }: MiniProps) {
return players;
},
enabled: shouldUpdate,
});
let players = data; // So we can update it later