AquaNet: Added an Error Message trigger to pages that didn't telegraph to the user that there was an error before.

pull/17/head
Galexion 2024-02-29 22:48:41 -05:00
parent 88b7804123
commit c4309aa14c
5 changed files with 45 additions and 16 deletions

View File

@ -0,0 +1,12 @@
<script>
export let ifError = `No Error was Passed through. Quick, check the Devtools and create a Ticket!`;
</script>
<blockquote>
<h2 style="color:red;">Something's wrong, Please Try again Later.</h2>
<p>Need to know why? Check Below.</p>
<code>
{ifError}
</code>
</blockquote>

View File

@ -129,7 +129,7 @@ export const GAME = {
userSummary: (username: string, game: GameName): Promise<GenericGameSummary> =>
post(`/api/v2/game/${game}/user-summary`, { username }),
ranking: (game: GameName): Promise<GenericRanking[]> =>
post(`/api/v2/game/${game}/ranking`, { }),
post(`/api/v2/game/${game}/ranking`, { }),
}

View File

@ -3,9 +3,11 @@
import {getMaimaiAllMusic, getMaimai} from "../libs/maimai";
import type {ParsedRating, Rating} from "../libs/maimaiTypes";
import { getMult } from "../libs/scoring";
import ErrorMessage from "../ErrorMessage.svelte";
export let userId: any
userId = +userId
let ifError = null;
if (!userId) console.error("No user ID provided")
@ -25,6 +27,8 @@
old: parseRating(data.userRating.ratingList),
new: parseRating(data.userRating.newRatingList)
}
}).catch((error) => {
ifError = error
})
function parseRating(arr: Rating[]) {
@ -91,7 +95,10 @@
{/each}
</div>
{/each}
{/if}
{:else if ifError}
<ErrorMessage {ifError}/>
{/if}
</main>
<style lang="sass">

View File

@ -2,16 +2,19 @@
import { clz, title } from "../libs/ui";
import { GAME } from "../libs/sdk";
import type { GenericRanking } from "../libs/generalTypes";
import ErrorMessage from "../ErrorMessage.svelte";
title(`Ranking`)
title(`Ranking`);
let d: { users: GenericRanking[] }
Promise.all([
GAME.ranking('mai2')
]).then(([ users ]) => {
d = { users }
})
let d: { users: GenericRanking[] };
let ifError = null;
Promise.all([GAME.ranking("mai2")])
.then(([users]) => {
d = { users };
})
.catch((error) => {
ifError = error;
});
</script>
<main class="content leaderboard">
@ -28,9 +31,9 @@
<span class="ap">AP</span>
</div>
{#each d.users as user, i (user.rank)}
<div class={clz({alternate: i % 2 === 1}, 'lb-user')}>
<div class={clz({ alternate: i % 2 === 1 }, "lb-user")}>
<span class="rank">#{user.rank}</span>
<span class="name">{user.name}</span>
<a class="name" href="/u/61702139">{user.name}</a>
<span class="rating">{user.rating.toLocaleString()}</span>
<span class="accuracy">{(+user.accuracy).toFixed(2)}%</span>
<span class="fc">{user.fullCombo}</span>
@ -38,6 +41,8 @@
</div>
{/each}
</div>
{:else if ifError}
<ErrorMessage {ifError}/>
{:else}
<p>Please Wait...</p>
{/if}
@ -87,4 +92,4 @@
&.alternate
background-color: $ov-light
</style>
</style>

View File

@ -8,6 +8,7 @@
import 'chartjs-adapter-moment';
import { DATA, GAME } from "../libs/sdk";
import { type GameName, getMult } from "../libs/scoring";
import ErrorMessage from "../ErrorMessage.svelte";
registerChart()
@ -15,7 +16,7 @@
export let game: GameName
game = game || "mai2"
let calElement: HTMLElement
let ifError = null
title(`User ${username}`)
interface MusicAndPlay extends MusicMeta, GenericGamePlaylog {}
@ -38,7 +39,9 @@
d = {user, trend, recent: user.recent.map(it => {return {...music[it.musicId], ...it}})}
localStorage.setItem("tmp-user-details", JSON.stringify(d))
renderCal(calElement, trend.map(it => {return {date: it.date, value: it.plays}}))
})
}).catch((error) => {
ifError = error;
});
const pfpNotFound = (e: Event) => {
(e.target as HTMLImageElement).src = "/assets/imgs/no_profile.png"
@ -191,7 +194,9 @@
{/each}
</div>
</div>
{:else}
{:else if ifError}
<ErrorMessage {ifError}/>
{:else}
<p>Loading...</p>
{/if}
</main>