Skip to content

Commit

Permalink
Fix build
Browse files Browse the repository at this point in the history
  • Loading branch information
mia-pi-git committed Oct 23, 2024
1 parent e597942 commit f5ce9fb
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,23 +58,24 @@ const suspects: Record<string, {startDate: number, reqs: SuspectReqs}> = loadDat
const coil: Record<string, number> = loadData(Config.coilpath);

if (Config.suspectpath) {
watchFile(Config.suspectpath,
watchFile(
Config.suspectpath,
() => Object.assign(suspects, loadData(Config.suspectpath))
);
}
if (Config.coilpath) {
watchFile(Config.coilpath, () => Object.assign(coil, loadData(Config.coilpath)));
}

const redundantFetch = async (url: string, data: RequestInit, attempts = 0): Promise<void> => {
const redundantFetch = async (targetUrl: string, data: RequestInit, attempts = 0): Promise<void> => {
if (attempts >= 10) return;
try {
await fetch(url, data);
await fetch(targetUrl, data);
} catch (e: any) {
if (e.code === 400) return console.error('400 on Smogon request', e, data);
return redundantFetch(url, data, attempts++);
return redundantFetch(targetUrl, data, attempts++);
}
}
};

export const actions: {[k: string]: QueryHandler} = {
async register(params) {
Expand Down Expand Up @@ -1043,7 +1044,6 @@ export const actions: {[k: string]: QueryHandler} = {
if (!(reqs.gxe || reqs.elo || reqs.coil) || Object.values(reqs).some(x => typeof x !== 'number')) {
throw new ActionError("Invalid reqs sent.");
}
const suspects = loadData(Config.suspectpath);
suspects[id] = {
startDate: time(),
reqs,
Expand Down

0 comments on commit f5ce9fb

Please sign in to comment.