fix: return old matchList from db if Riot API is down

This commit is contained in:
Valentin Kaelin 2020-01-01 16:22:40 +01:00
parent 9d2854ad25
commit 1c9e2b8d70

View file

@ -15,7 +15,12 @@ class MatchService {
let alreadyIn = false
let index = 0
do {
let newMatchList = (await Jax.Matchlist.accountID(account.accountId, account.region, index)).matches
let newMatchList = await Jax.Matchlist.accountID(account.accountId, account.region, index)
// Error while fetching Riot API
if (!newMatchList) {
return matchList
}
newMatchList = newMatchList.matches
matchList = [...matchList, ...newMatchList]
alreadyIn = newMatchList.length === 0 || stopFetching(newMatchList)
// If the match is made in another region : we stop fetching