fix avatars not loading if the player doesn't have a avatar

This commit is contained in:
Lee 2023-10-18 05:57:23 +01:00
parent de1987bfec
commit c07f82899c
2 changed files with 16 additions and 6 deletions

@ -1,14 +1,22 @@
<script>
import {opt} from '../../utils/js'
import { opt } from '../../utils/js';
export let player;
$: avatar = opt(player, 'playerInfo.avatar')
const avatar = opt(player, 'playerInfo.avatar')
// TEMP WORKAROUND UNTIL I MIGRATE TO NEW SS API
export let avatarr;
if (avatar.includes("oculus")) {
avatarr = "https://cdn.scoresaber.com/avatars/oculus.png"
} else {
avatarr = `https://cdn.scoresaber.com/avatars/${player.playerId}.jpg`
}
</script>
{#if avatar}
{#if avatarr}
<figure class="image is-24x24" on:click>
<img src={avatar} alt=""/>
<img src={avatarr} alt=""/>
</figure>
{/if}

@ -1,5 +1,6 @@
<script>
import Spinner from '../Common/Spinner.svelte'
import { SS_CDN_HOST } from '../../network/queues/scoresaber/page-queue';
import Spinner from '../Common/Spinner.svelte';
export let playerInfo;
export let isLoading = false;
@ -10,7 +11,8 @@
<span class="no-image">?</span>
{#if playerInfo && playerInfo.avatar}
<img src={playerInfo.avatar} class="avatar" alt="" />
<!-- TEMP WORKAROUND UNTIL I MIGRATE TO NEW SS API -->
<img src={playerInfo.avatar.replace("https://new.scoresaber.com/api/static", SS_CDN_HOST)} class="avatar" alt="" />
{/if}
<span class="spinner">
<Spinner width="100%" height="100%"/>