diff --git a/src/lib/global.ts b/src/lib/global.ts index 9c79401..d6ad204 100644 --- a/src/lib/global.ts +++ b/src/lib/global.ts @@ -2,11 +2,14 @@ import { writable } from 'svelte/store'; import { ezppfarm } from './api/ezpp'; export const server_ping = writable(undefined); -const server_connection_fails = writable(0); +export const server_connection_fails = writable(0); +export let server_no_connection = false; export const online_friends = writable(undefined); -export const beatmap_sets = writable(undefined) +export const beatmap_sets = writable(undefined); + +export const updateNoConnection = (noConnection: boolean) => (server_no_connection = noConnection); export const setupValues = () => { updatePing(); @@ -23,7 +26,7 @@ export const setupValues = () => { const updatePing = async () => { const serverPing = await ezppfarm.ping(); - if (!serverPing) { + if (!serverPing || server_no_connection) { server_connection_fails.update((num) => num + 1); } else { server_connection_fails.set(0); @@ -32,9 +35,13 @@ const updatePing = async () => { }; const updateFriends = async () => { - await new Promise((res) => setTimeout(res, Math.random() * 1000)); - const onlineFriends = Math.round(Math.random() * 10); - online_friends.set(onlineFriends); + await new Promise((res) => setTimeout(res, Math.random() * 300)); + if (server_no_connection) { + online_friends.set(undefined); + } else { + const onlineFriends = Math.round(Math.random() * 10); + online_friends.set(onlineFriends); + } }; const updateBeatmapSets = async () => { diff --git a/src/routes/+page.svelte b/src/routes/+page.svelte index cefef4c..ce5858f 100644 --- a/src/routes/+page.svelte +++ b/src/routes/+page.svelte @@ -3,13 +3,21 @@ import Badge from '@/components/ui/badge/badge.svelte'; import Button from '@/components/ui/button/button.svelte'; import * as Select from '@/components/ui/select'; - import { beatmap_sets, online_friends, server_ping } from '@/global'; + import { + beatmap_sets, + online_friends, + server_connection_fails, + server_no_connection, + server_ping, + updateNoConnection, + } from '@/global'; import { WebviewWindow } from '@tauri-apps/api/webviewWindow'; - import { LoaderCircle, Logs, Music2, Play, Users, Wifi, Gamepad2 } from 'lucide-svelte'; + import { LoaderCircle, Logs, Music2, Play, Users, Wifi, Gamepad2, WifiOff } from 'lucide-svelte'; import { Circle } from 'radix-icons-svelte'; import NumberFlow from '@number-flow/svelte'; import * as AlertDialog from '@/components/ui/alert-dialog'; import Progress from '@/components/ui/progress/progress.svelte'; + import { numberHumanReadable } from '@/utils'; let selectedTab = $state('home'); let launching = $state(false); @@ -28,12 +36,15 @@
- + - User + Quetzalcoatl +
+ Owner +
@@ -142,19 +153,32 @@
-
- +
+ {#if $server_connection_fails > 1} + + {:else} + + {/if}
-
+
1 ? 'opacity-100' : 'opacity-0'} transition-opacity duration-1000" >
1 ? 'opacity-0' : 'opacity-100'} transition-opacity duration-1000" > @@ -166,19 +190,34 @@
-
- +
+ {#if $server_connection_fails > 1} + + {:else} + + {/if}
-
+
1 ? 'opacity-100' : 'opacity-0'} transition-opacity duration-1000" >
@@ -198,6 +237,17 @@ Launch + {#key server_no_connection} + + {/key}
@@ -206,13 +256,15 @@
osu! Version - 20250626.1 + + 20250626.1 + Beatmap Sets - {$beatmap_sets} + {numberHumanReadable($beatmap_sets ?? 0)} Skins - 727 + {numberHumanReadable(727)}