Skip to content

Commit

Permalink
Fix: Remove temporal fix and show notification of loading
Browse files Browse the repository at this point in the history
  • Loading branch information
thejaviertc committed Feb 11, 2024
1 parent 1d0c221 commit d464f17
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 28 deletions.
33 changes: 19 additions & 14 deletions src/routes/user/id/[slug]/+page.svelte
Original file line number Diff line number Diff line change
@@ -1,26 +1,31 @@
<script lang="ts">
import { page } from "$app/stores";
import type { ISteamUser } from "$lib/ISteamUser";
import SteamApi from "$lib/SteamApi";
import { faExclamationCircle } from "@fortawesome/free-solid-svg-icons";
import { onMount } from "svelte";
import { faCircleInfo, faExclamationCircle } from "@fortawesome/free-solid-svg-icons";
import { _ } from "svelte-i18n";
import Notification from "$components/Notification.svelte";
import UserStats from "$components/UserStats.svelte";
let user: ISteamUser = { addons: {} };
onMount(async () => {
user = await SteamApi.getSteamUser("id", $page.params.slug);
});
async function getUser() {
return await SteamApi.getSteamUser("id", $page.params.slug);
}
</script>

<section class="min-h-screen mt-28">
{#if user.message}
<Notification class="bg-error" faIcon={faExclamationCircle}>
{user.message}
{#await getUser()}
<Notification class="bg-warning" faIcon={faCircleInfo}>
{$_("notifications.disclaimer")}
</Notification>
{:else}
<UserStats steamUser={user} />
{/if}
{:then data}
{#if data.message}
<Notification class="bg-error" faIcon={faExclamationCircle}>
{data.message}
</Notification>
{:else}
<UserStats steamUser={data} />
{/if}
{:catch error}
<h2>{error}</h2>
{/await}
</section>
33 changes: 19 additions & 14 deletions src/routes/user/profiles/[slug]/+page.svelte
Original file line number Diff line number Diff line change
@@ -1,26 +1,31 @@
<script lang="ts">
import { page } from "$app/stores";
import type { ISteamUser } from "$lib/ISteamUser";
import SteamApi from "$lib/SteamApi";
import { faExclamationCircle } from "@fortawesome/free-solid-svg-icons";
import { onMount } from "svelte";
import { faCircleInfo, faExclamationCircle } from "@fortawesome/free-solid-svg-icons";
import { _ } from "svelte-i18n";
import Notification from "$components/Notification.svelte";
import UserStats from "$components/UserStats.svelte";
let user: ISteamUser = { addons: {} };
onMount(async () => {
user = await SteamApi.getSteamUser("profiles", $page.params.slug);
});
async function getUser() {
return await SteamApi.getSteamUser("profiles", $page.params.slug);
}
</script>

<section class="min-h-screen mt-28">
{#if user.message}
<Notification class="bg-error" faIcon={faExclamationCircle}>
{user.message}
{#await getUser()}
<Notification class="bg-warning" faIcon={faCircleInfo}>
{$_("notifications.disclaimer")}
</Notification>
{:else}
<UserStats steamUser={user} />
{/if}
{:then data}
{#if data.message}
<Notification class="bg-error" faIcon={faExclamationCircle}>
{data.message}
</Notification>
{:else}
<UserStats steamUser={data} />
{/if}
{:catch error}
<h2>{error}</h2>
{/await}
</section>

0 comments on commit d464f17

Please sign in to comment.