poll for matches to complete

This commit is contained in:
Ilion Beyst 2022-02-22 19:44:29 +01:00
parent 006ce35622
commit e15944622d

View file

@ -55,15 +55,30 @@
let matchData = responseData["match"]; let matchData = responseData["match"];
matches.push(matchData); matches.unshift(matchData);
matches = matches; matches = matches;
selectMatch(matchData["id"]);
} }
async function selectMatch(matchId: string) { async function selectMatch(matchId: string) {
console.log("showing match " + matchId);
let matchLog = await getMatchLog(matchId);
selectedMatchId = matchId; selectedMatchId = matchId;
selectedMatchLog = null;
fetchSelectedMatchLog(matchId);
}
async function fetchSelectedMatchLog(matchId: string) {
if (matchId !== selectedMatchId) {
return;
}
let matchLog = await getMatchLog(matchId);
if (matchLog) {
selectedMatchLog = matchLog; selectedMatchLog = matchLog;
} else {
// try again in 1 second
setTimeout(fetchSelectedMatchLog, 1000, matchId);
}
} }
async function getMatchData(matchId: string) { async function getMatchData(matchId: string) {