fix crying
This commit is contained in:
@ -6,13 +6,14 @@ import { getAverageColor } from "@/common/image-utils";
|
||||
import { scoresaberService } from "@ssr/common/service/impl/scoresaber";
|
||||
import { getCookieValue } from "@ssr/common/utils/cookie-utils";
|
||||
import { Config } from "@ssr/common/config";
|
||||
import ScoreSaberPlayer, { getScoreSaberPlayerFromToken } from "@ssr/common/player/impl/scoresaber-player";
|
||||
import ScoreSaberPlayer from "@ssr/common/player/impl/scoresaber-player";
|
||||
import { ScoreSort } from "@ssr/common/score/score-sort";
|
||||
import { ScoreSaberScore } from "@ssr/common/model/score/impl/scoresaber-score";
|
||||
import ScoreSaberLeaderboard from "@ssr/common/leaderboard/impl/scoresaber-leaderboard";
|
||||
import { fetchPlayerScores } from "@ssr/common/utils/score-utils";
|
||||
import PlayerScoresResponse from "@ssr/common/response/player-scores-response";
|
||||
import { SSRCache } from "@ssr/common/cache";
|
||||
import { getScoreSaberPlayerFromToken } from "@ssr/common/token-creators";
|
||||
|
||||
const UNKNOWN_PLAYER = {
|
||||
title: "ScoreSaber Reloaded - Unknown Player",
|
||||
|
@ -13,11 +13,12 @@ import PlayerCharts from "@/components/player/chart/player-charts";
|
||||
import { scoresaberService } from "@ssr/common/service/impl/scoresaber";
|
||||
import useDatabase from "@/hooks/use-database";
|
||||
import { useLiveQuery } from "dexie-react-hooks";
|
||||
import ScoreSaberPlayer, { getScoreSaberPlayerFromToken } from "@ssr/common/player/impl/scoresaber-player";
|
||||
import ScoreSaberPlayer from "@ssr/common/player/impl/scoresaber-player";
|
||||
import { ScoreSort } from "@ssr/common/score/score-sort";
|
||||
import { ScoreSaberScore } from "@ssr/common/model/score/impl/scoresaber-score";
|
||||
import ScoreSaberLeaderboard from "@ssr/common/leaderboard/impl/scoresaber-leaderboard";
|
||||
import PlayerScoresResponse from "@ssr/common/response/player-scores-response";
|
||||
import { getScoreSaberPlayerFromToken } from "@ssr/common/token-creators";
|
||||
|
||||
type Props = {
|
||||
initialPlayerData: ScoreSaberPlayer;
|
||||
|
@ -2,13 +2,12 @@
|
||||
|
||||
import { useEffect, useState } from "react";
|
||||
import ScoreSaberPlayerScoreToken from "@ssr/common/types/token/scoresaber/score-saber-player-score-token";
|
||||
import Score from "@/components/score/score";
|
||||
import { parseDate } from "@ssr/common/utils/time-utils";
|
||||
import Link from "next/link";
|
||||
import useWebSocket, { ReadyState } from "react-use-websocket";
|
||||
import { ScoreSaberWebsocketMessageToken } from "@ssr/common/types/token/scoresaber/websocket/scoresaber-websocket-message";
|
||||
import { getScoreSaberScoreFromToken } from "@ssr/common/model/score/impl/scoresaber-score";
|
||||
import { getScoreSaberLeaderboardFromToken } from "@ssr/common/leaderboard/impl/scoresaber-leaderboard";
|
||||
import Score from "@/components/score/score";
|
||||
import { getScoreSaberLeaderboardFromToken, getScoreSaberScoreFromToken } from "@ssr/common/token-creators";
|
||||
|
||||
export default function ScoreFeed() {
|
||||
const { readyState, lastJsonMessage } = useWebSocket<ScoreSaberWebsocketMessageToken>("wss://scoresaber.com/ws");
|
||||
@ -40,12 +39,18 @@ export default function ScoreFeed() {
|
||||
|
||||
return (
|
||||
<div className="flex flex-col divide-y divide-border">
|
||||
{scores.map(score => {
|
||||
const player = score.score.leaderboardPlayerInfo;
|
||||
const leaderboard = getScoreSaberLeaderboardFromToken(score.leaderboard);
|
||||
{scores.map(scoreToken => {
|
||||
if (!scoreToken.leaderboard || !scoreToken.score) {
|
||||
console.error("Invalid leaderboard or score data:", scoreToken);
|
||||
return null;
|
||||
}
|
||||
|
||||
const player = scoreToken.score.leaderboardPlayerInfo;
|
||||
const leaderboard = getScoreSaberLeaderboardFromToken(scoreToken.leaderboard);
|
||||
const score = getScoreSaberScoreFromToken(scoreToken.score, leaderboard);
|
||||
|
||||
return (
|
||||
<div key={score.score.id} className="flex flex-col py-2">
|
||||
<div key={score.scoreId} className="flex flex-col py-2">
|
||||
<p className="text-sm">
|
||||
Set by{" "}
|
||||
<Link href={`/player/${player.id}`}>
|
||||
@ -53,7 +58,7 @@ export default function ScoreFeed() {
|
||||
</Link>
|
||||
</p>
|
||||
<Score
|
||||
score={getScoreSaberScoreFromToken(score.score, leaderboard)}
|
||||
score={score}
|
||||
leaderboard={leaderboard}
|
||||
settings={{
|
||||
noScoreButtons: true,
|
||||
|
@ -23,6 +23,11 @@ import { ScoreStatsToken } from "@ssr/common/types/token/beatleader/score-stats/
|
||||
import { beatLeaderService } from "@ssr/common/service/impl/beatleader";
|
||||
|
||||
type Props = {
|
||||
/**
|
||||
* The score to display.
|
||||
*/
|
||||
score: ScoreSaberScore;
|
||||
|
||||
/**
|
||||
* The leaderboard.
|
||||
*/
|
||||
@ -33,11 +38,6 @@ type Props = {
|
||||
*/
|
||||
beatSaverMap?: BeatSaverMap;
|
||||
|
||||
/**
|
||||
* The score to display.
|
||||
*/
|
||||
score: ScoreSaberScore;
|
||||
|
||||
/**
|
||||
* Score settings
|
||||
*/
|
||||
@ -123,7 +123,7 @@ export default function Score({ leaderboard, beatSaverMap, score, settings }: Pr
|
||||
useEffect(() => {
|
||||
setIsLeaderboardExpanded(false);
|
||||
setLeaderboardDropdownData(undefined);
|
||||
}, [score]);
|
||||
}, [score.scoreId]);
|
||||
|
||||
const accuracy = (baseScore / leaderboard.maxScore) * 100;
|
||||
const pp = baseScore === score.score ? score.pp : scoresaberService.getPp(leaderboard.stars, accuracy);
|
||||
|
Reference in New Issue
Block a user