refactor: use loadingOptions for leaderboards page

This commit is contained in:
Miodec 2025-12-22 22:44:52 +01:00
parent 5d169e933a
commit 765ca9569f
3 changed files with 10 additions and 4 deletions

View file

@ -275,9 +275,9 @@ export async function change(
typeof nextPageLoadingMode === "object" &&
nextPageLoadingMode.mode === "async"
) {
nextPageLoadingMode.beforeLoading();
nextPageLoadingMode.beforeLoading?.();
void nextPage?.loadingOptions?.loadingPromise().then(() => {
nextPageLoadingMode.afterLoading();
nextPageLoadingMode.afterLoading?.();
});
}

View file

@ -1485,13 +1485,19 @@ export const page = new PageWithUrlParams({
element: qsr(".page.pageLeaderboards"),
path: "/leaderboards",
urlParamsSchema: UrlParameterSchema,
loadingOptions: {
style: "spinner",
loadingMode: () => "sync",
loadingPromise: async () => {
await ServerConfiguration.configurationPromise;
},
},
afterHide: async (): Promise<void> => {
Skeleton.remove("pageLeaderboards");
stopTimer();
},
beforeShow: async (options): Promise<void> => {
await ServerConfiguration.configurationPromise;
Skeleton.append("pageLeaderboards", "main");
await updateValidDailyLeaderboards();
await appendModeAndLanguageButtons();

View file

@ -34,7 +34,7 @@ export type LoadingOptions = {
loadingMode: () =>
| "none"
| "sync"
| { mode: "async"; beforeLoading: () => void; afterLoading: () => void };
| { mode: "async"; beforeLoading?: () => void; afterLoading?: () => void };
/**
* When this promise resolves, the loading screen will be hidden.
*/