Skip to content

Commit 17c8f6d

Browse files
committed
impr: show loading bar when fetching language/quotes to indicate background activity
1 parent 8ec109d commit 17c8f6d

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

frontend/src/ts/test/test-logic.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ import { SnapshotResult } from "../constants/default-snapshot";
7676
import { WordGenError } from "../utils/word-gen-error";
7777
import { tryCatch } from "@monkeytype/util/trycatch";
7878
import { captureException } from "../sentry";
79+
import * as Loader from "../elements/loader";
7980

8081
let failReason = "";
8182
const koInputVisual = document.getElementById("koInputVisual") as HTMLElement;
@@ -410,9 +411,12 @@ export async function init(): Promise<void> {
410411
TestInput.input.resetHistory();
411412
TestInput.input.current = "";
412413

414+
Loader.show();
413415
const { data: language, error } = await tryCatch(
414416
JSONData.getLanguage(Config.language)
415417
);
418+
Loader.hide();
419+
416420
if (error) {
417421
Notifications.add(
418422
Misc.createErrorMessage(error, "Failed to load language"),

frontend/src/ts/test/words-generator.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import {
2323
isFunboxActiveWithFunction,
2424
} from "./funbox/list";
2525
import { WordGenError } from "../utils/word-gen-error";
26+
import * as Loader from "../elements/loader";
2627

2728
function shouldCapitalize(lastChar: string): boolean {
2829
return /[?!.؟]/.test(lastChar);
@@ -499,10 +500,12 @@ async function getQuoteWordList(
499500
? "german"
500501
: language.name;
501502

503+
Loader.show();
502504
const quotesCollection = await QuotesController.getQuotes(
503505
languageToGet,
504506
Config.quoteLength
505507
);
508+
Loader.hide();
506509

507510
if (quotesCollection.length === 0) {
508511
UpdateConfig.setMode("words");

0 commit comments

Comments
 (0)