Skip to content

Commit 12cde3f

Browse files
committed
Minor fixes
1 parent f9faac4 commit 12cde3f

File tree

1 file changed

+26
-4
lines changed

1 file changed

+26
-4
lines changed

ReplayBrowser/Pages/Shared/CompactProfileDisplay.razor

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,35 @@
4141
fields.push("Last seen: " + timeDifference(new Date(), lastPlayedParsedUtcDate));
4242
fields.push("Rounds played: " + data.totalRoundsPlayed);
4343
fields.push("Total antag rounds played: " + data.totalAntagRoundsPlayed);
44-
let mostPlayedCharacter = data.characters.sort((a, b) => b.roundsPlayed - a.roundsPlayed)[0];
45-
fields.push("Most played character: " + mostPlayedCharacter.characterName + " (" + mostPlayedCharacter.roundsPlayed + " rounds)");
46-
let mostPlayedJob = data.jobCount.sort((a, b) => b.roundsPlayed - a.roundsPlayed)[0];
47-
fields.push("Most played job: " + mostPlayedJob.jobPrototype + " (" + mostPlayedJob.roundsPlayed + " rounds)");
44+
if (data.characters.length == 0) {
45+
fields.push("No character data available");
46+
} else {
47+
let mostAntagCharacter = data.characters.sort((a, b) => b.antagRoundsPlayed - a.antagRoundsPlayed)[0];
48+
fields.push("Most antag rounds played: " + mostAntagCharacter.characterName + " (" + mostAntagCharacter.antagRoundsPlayed + " rounds)");
49+
}
50+
if (data.jobCount.length == 0) {
51+
fields.push("No job data available");
52+
} else {
53+
let mostPlayedJob = data.jobCount.sort((a, b) => b.roundsPlayed - a.roundsPlayed)[0];
54+
fields.push("Most played job: " + mostPlayedJob.jobPrototype + " (" + mostPlayedJob.roundsPlayed + " rounds)");
55+
}
4856
4957
$("#content-text-" + "@ProfileId").html(fields.join("<br>"));
5058
59+
// Finish loading
60+
$("#loading-spinner-" + "@ProfileId").addClass("hidden");
61+
},
62+
error: function(data) {
63+
console.error(data);
64+
// if we got a unauthorized response, profile is private
65+
if (data.status == 401) {
66+
$("#content-title-" + "@ProfileId").text("Private profile");
67+
$("#content-text-" + "@ProfileId").text("This profile is private, you can't see any data.");
68+
} else {
69+
$("#content-title-" + "@ProfileId").text("Error");
70+
$("#content-text-" + "@ProfileId").text("An error occurred while fetching data.");
71+
}
72+
5173
// Finish loading
5274
$("#loading-spinner-" + "@ProfileId").addClass("hidden");
5375
}

0 commit comments

Comments
 (0)