Skip to content

Commit 55e3dd9

Browse files
committed
fix tape sometimes calculates before funbox css is loaded on quick restart
1 parent f650130 commit 55e3dd9

1 file changed

Lines changed: 32 additions & 7 deletions

File tree

frontend/src/ts/test/funbox/funbox.ts

Lines changed: 32 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -219,16 +219,41 @@ async function setFunboxBodyClasses(): Promise<boolean> {
219219
return true;
220220
}
221221

222-
async function applyFunboxCSS(): Promise<boolean> {
222+
async function applyFunboxCSS(): Promise<void> {
223223
qsa(".funBoxTheme").remove();
224+
225+
await Promise.all(
226+
getActiveFunboxesWithProperty("hasCssFile").map(
227+
async (funbox) =>
228+
new Promise<void>((resolve, reject) => {
229+
const css = document.createElement("link");
230+
css.classList.add("funBoxTheme");
231+
css.rel = "stylesheet";
232+
css.href = "funbox/" + funbox.name + ".css";
233+
css.onload = () => resolve();
234+
css.onerror = reject;
235+
document.head.appendChild(css);
236+
}),
237+
),
238+
);
239+
240+
/*
241+
const promises = [];
224242
for (const funbox of getActiveFunboxesWithProperty("hasCssFile")) {
225-
const css = document.createElement("link");
226-
css.classList.add("funBoxTheme");
227-
css.rel = "stylesheet";
228-
css.href = "funbox/" + funbox.name + ".css";
229-
document.head.appendChild(css);
243+
promises.push(
244+
new Promise<void>((resolve, reject) => {
245+
const css = document.createElement("link");
246+
css.classList.add("funBoxTheme");
247+
css.rel = "stylesheet";
248+
css.href = "funbox/" + funbox.name + ".css";
249+
css.onload = () => resolve();
250+
css.onerror = reject;
251+
document.head.appendChild(css);
252+
}),
253+
);
230254
}
231-
return true;
255+
await Promise.all(promises);
256+
*/
232257
}
233258

234259
configEvent.subscribe(async ({ key }) => {

0 commit comments

Comments
 (0)