Skip to content

Commit fb0023d

Browse files
committed
hundle null score in replay stats
1 parent e052001 commit fb0023d

4 files changed

Lines changed: 15 additions & 4 deletions

File tree

app/Libraries/Transformers/Scope.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,10 @@ protected function fireTransformer($transformer, $data): array
121121
}
122122
}
123123

124-
[$transformedData, $includedData] = parent::fireTransformer($transformer, $data);
124+
// mergeIncludes called by fireTransformers requires arrays, so just skip calling everything if data is null.
125+
if ($data !== null) {
126+
[$transformedData, $includedData] = parent::fireTransformer($transformer, $data);
127+
}
125128

126129
if (empty($transformedData) && empty($includedData)) {
127130
return [null, []];

app/Transformers/ScoreTransformer.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,12 @@ public function __construct(?bool $legacyFormat = null)
6363
$this->legacyFormat = $legacyFormat ?? (is_api_request() && api_version() < 20220705);
6464
}
6565

66-
public function transform(LegacyMatch\Score|MultiplayerScoreLink|SoloScore $score)
66+
public function transform(LegacyMatch\Score|MultiplayerScoreLink|SoloScore|null $score)
6767
{
68+
if ($score === null) {
69+
return null;
70+
}
71+
6872
if ($this->legacyFormat) {
6973
return $this->transformLegacy($score);
7074
}

resources/js/interfaces/score-replay-stats-json.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import ScoreJson, { ScoreJsonForUser } from './score-json';
55

66
interface ScoreReplayStatsJsonAvailableIncludes {
7-
score: ScoreJson;
7+
score: ScoreJson|null;
88
}
99

1010
interface ScoreReplayStatsJsonDefaultAttributes {
@@ -16,4 +16,4 @@ type ScoreReplayStatsJson = ScoreReplayStatsJsonDefaultAttributes & Partial<Scor
1616

1717
export default ScoreReplayStatsJson;
1818

19-
export type ScoreReplayStatsJsonForUser = ScoreReplayStatsJson & { score: ScoreJsonForUser };
19+
export type ScoreReplayStatsJsonForUser = ScoreReplayStatsJson & { score: ScoreJsonForUser|null };

resources/js/profile-page/score-replay-stats-entry.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ export default function ScoreReplayStatsEntry(props: Props) {
2525
const user = props.user;
2626
const stats = props.stats;
2727
const score = stats.score;
28+
if (score == null) {
29+
return null;
30+
}
31+
2832
const scoreRank = rank(score);
2933
const { beatmap, beatmapset } = score;
3034

0 commit comments

Comments
 (0)