Skip to content

Commit 286fa8c

Browse files
committed
fetch my games in parallel
1 parent defcd46 commit 286fa8c

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

my.html

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -312,17 +312,19 @@ <h3 style="display: inline-block;"><a href="/about">© Borg Queen, LLC 2024</a><
312312
async function reloadGameList() {
313313
gameList.innerHTML = '';
314314
gameList.size = 0;
315+
My.resetGames();
315316

316317
const response = await OneDrive.makeRequest('special/approot:/PCs:/children');
317318
if (!response.ok) {
318319
throw new Error(`HTTP ${response.status}: ${response.statusText}`);
319320
}
320321
const json = await response.json();
321322
const items = json.value;
322-
for (const item of items) {
323-
if (!item.hasOwnProperty('folder')) continue;
324-
await My.getGames(item.name, gameList);
325-
}
323+
const pcs = items
324+
.filter((item) => item.hasOwnProperty('folder'))
325+
.map((item) => item.name);
326+
327+
await Promise.all(pcs.map((pc) => My.getGames(pc, gameList)));
326328

327329
const noPCs = document.getElementById('no-pcs');
328330
if (items.length === 0) {

ts/my.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,12 @@ interface IMyGame {
99
export class Games {
1010
static games: Record<string, IMyGame> = {};
1111
}
12+
13+
export function resetGames() {
14+
for (const key of Object.keys(Games.games)) {
15+
delete Games.games[key];
16+
}
17+
}
1218
export async function getGames(pc: string, list: HTMLSelectElement) {
1319
let json = null;
1420
try {

0 commit comments

Comments
 (0)