aboutsummaryrefslogtreecommitdiff
path: root/web/pw-server/src/routes
diff options
context:
space:
mode:
Diffstat (limited to 'web/pw-server/src/routes')
-rw-r--r--web/pw-server/src/routes/index.svelte23
1 files changed, 19 insertions, 4 deletions
diff --git a/web/pw-server/src/routes/index.svelte b/web/pw-server/src/routes/index.svelte
index 59552bc..7b364be 100644
--- a/web/pw-server/src/routes/index.svelte
+++ b/web/pw-server/src/routes/index.svelte
@@ -55,15 +55,30 @@
let matchData = responseData["match"];
- matches.push(matchData);
+ matches.unshift(matchData);
matches = matches;
+ selectMatch(matchData["id"]);
}
async function selectMatch(matchId: string) {
- console.log("showing match " + matchId);
- let matchLog = await getMatchLog(matchId);
selectedMatchId = matchId;
- selectedMatchLog = matchLog;
+ selectedMatchLog = null;
+ fetchSelectedMatchLog(matchId);
+ }
+
+ async function fetchSelectedMatchLog(matchId: string) {
+ if (matchId !== selectedMatchId) {
+ return;
+ }
+
+ let matchLog = await getMatchLog(matchId);
+
+ if (matchLog) {
+ selectedMatchLog = matchLog;
+ } else {
+ // try again in 1 second
+ setTimeout(fetchSelectedMatchLog, 1000, matchId);
+ }
}
async function getMatchData(matchId: string) {