[+] Show aqua net pfp instead of in-game pfp

This commit is contained in:
Azalea
2024-03-06 00:37:35 -05:00
parent 2a10471e0b
commit 52ec890e2c
9 changed files with 22 additions and 21 deletions

View File

@@ -12,7 +12,7 @@ export interface Card {
ghost: boolean
}
export interface UserMe {
export interface AquaNetUser {
username: string
email: string
displayName: string
@@ -80,6 +80,7 @@ export interface RankCount {
export interface GenericGameSummary {
name: string
iconId: number
aquaUser?: AquaNetUser
serverRank: number
accuracy: number
rating: number

View File

@@ -6,7 +6,7 @@ import type {
GenericGameSummary,
GenericRanking,
TrendEntry,
UserMe
AquaNetUser
} from "./generalTypes";
import type { GameName } from "./scoring";
@@ -111,7 +111,7 @@ export const USER = {
login,
confirmEmail: (token: string) =>
post('/api/v2/user/confirm-email', { token }),
me: (): Promise<UserMe> => {
me: (): Promise<AquaNetUser> => {
ensureLoggedIn()
return post('/api/v2/user/me', {})
},

View File

@@ -16,7 +16,7 @@ import CalHeatmap from 'cal-heatmap'
// @ts-expect-error Cal-heatmap does not have proper types
import CalTooltip from 'cal-heatmap/plugins/Tooltip'
import { AQUA_HOST, DEFAULT_PFP } from "./config";
import type { UserMe } from "./generalTypes";
import type { AquaNetUser } from "./generalTypes";
export function title(t: string) {
document.title = `AquaNet - ${t}`
@@ -154,7 +154,7 @@ export function tooltip(element: HTMLElement, params: { text: string } | string)
}
}
export function pfp(node: HTMLImageElement, me: UserMe) {
node.src = me.profilePicture ? `${AQUA_HOST}/uploads/net/portrait/${me.profilePicture}` : DEFAULT_PFP
export function pfp(node: HTMLImageElement, me?: AquaNetUser) {
node.src = me?.profilePicture ? `${AQUA_HOST}/uploads/net/portrait/${me.profilePicture}` : DEFAULT_PFP
node.onerror = e => pfpNotFound(e as Event)
}