mirror of
https://github.com/monkeytypegame/monkeytype.git
synced 2026-01-12 18:34:05 +08:00
refactor: use loadingOptions for leaderboards page
This commit is contained in:
parent
5d169e933a
commit
765ca9569f
3 changed files with 10 additions and 4 deletions
|
|
@ -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?.();
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -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.
|
||||
*/
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue