import type { RankingKind, RankingPage } from '~/types/game' /** One world's ranking: a page of one kind. */ export function useRanking(worldId: number) { const page = ref(null) const error = ref(null) const busy = ref(false) const errorText = useErrorText() /** Without a page, the server opens on the one with the own row. */ async function load(kind: RankingKind, at?: number) { busy.value = true error.value = null try { page.value = await ws.send('ranking.index', { world_id: worldId, kind, page: at ?? null }) } catch (e) { error.value = errorText(e) } finally { busy.value = false } } return { page, error, busy, load } }