MCPcopy
hub / github.com/monkeytypegame/monkeytype / setup

Function setup

frontend/src/ts/controllers/challenge-controller.ts:210–411  ·  view source on GitHub ↗
(challengeName: string)

Source from the content-addressed store, hash-verified

208}
209
210export async function setup(challengeName: string): Promise<boolean> {
211 challengeLoading = true;
212
213 setConfig("funbox", []);
214
215 const { data: list, error } = await tryCatch(JSONData.getChallengeList());
216 if (error) {
217 showErrorNotification("Failed to setup challenge", { error });
218 setTimeout(() => {
219 qs("header .config")?.show();
220 qs(".page.pageTest")?.show();
221 }, 250);
222 return false;
223 }
224
225 const challenge = list.find(
226 (c) => c.name.toLowerCase() === challengeName.toLowerCase(),
227 );
228 let notitext;
229 try {
230 if (challenge === undefined) {
231 showNoticeNotification("Challenge not found");
232 setTimeout(() => {
233 qs("header .config")?.show();
234 qs(".page.pageTest")?.show();
235 }, 250);
236 return false;
237 }
238 if (challenge.type === "customTime") {
239 setConfig("time", challenge.parameters[0] as number, {
240 nosave: true,
241 });
242 setConfig("mode", "time", {
243 nosave: true,
244 });
245 setConfig("difficulty", "normal", {
246 nosave: true,
247 });
248 if (challenge.name === "englishMaster") {
249 setConfig("language", "english_10k", {
250 nosave: true,
251 });
252 setConfig("numbers", true, {
253 nosave: true,
254 });
255 setConfig("punctuation", true, {
256 nosave: true,
257 });
258 }
259 } else if (challenge.type === "customWords") {
260 setConfig("words", challenge.parameters[0] as number, {
261 nosave: true,
262 });
263 setConfig("mode", "words", {
264 nosave: true,
265 });
266 setConfig("difficulty", "normal", {
267 nosave: true,

Callers

nothing calls this directly

Calls 8

setConfigFunction · 0.90
tryCatchFunction · 0.90
showErrorNotificationFunction · 0.90
qsFunction · 0.90
showNoticeNotificationFunction · 0.90
showSuccessNotificationFunction · 0.90
setTextMethod · 0.80
showMethod · 0.45

Tested by

no test coverage detected