fix: add new matches to MatchList in a correct order

This commit is contained in:
Valentin Kaelin 2019-10-06 17:31:43 +02:00
parent a7561a82b8
commit 7f72112bc5

View file

@ -41,10 +41,10 @@ class MatchHelper {
return summonerDB.matchList.some(m => m.gameId === newMatchList[newMatchList.length - 1].gameId) return summonerDB.matchList.some(m => m.gameId === newMatchList[newMatchList.length - 1].gameId)
}) })
// Update Summoner's MatchList // Update Summoner's MatchList
for (const match of matchList) { for (const match of matchList.reverse()) {
if (!summonerDB.matchList.some(m => m.gameId === match.gameId)) { if (!summonerDB.matchList.some(m => m.gameId === match.gameId)) {
Logger.transport('file').info(`Match ${match.gameId} has been added to ${account.name}'s MatchList.`) Logger.transport('file').info(`Match ${match.gameId} has been added to ${account.name}'s MatchList.`)
summonerDB.matchList.push(match) summonerDB.matchList.unshift(match)
} }
} }
await summonerDB.save() await summonerDB.save()