feat: add "new" tag if first load of the match

This commit is contained in:
Valentin Kaelin 2020-04-01 14:14:03 +02:00
parent 1f7261f0ed
commit a573a7411e
2 changed files with 8 additions and 5 deletions

View file

@ -7,6 +7,11 @@
class="match relative bg-blue-800 text-white text-base cursor-pointer hover:shadow-xl"
>
<div class="relative flex flex-wrap px-5 py-3">
<div
v-if="data.newMatch"
class="new-match absolute right-0 top-0 px-2 text-xxs rounded-full"
style="margin: 0.35rem 0.35rem 0 0; background-color: rgba(99,179,237, .2);"
>New</div>
<div class="first w-4/12 text-left">
<div>
<div

View file

@ -102,10 +102,8 @@ class MatchService {
for (let i = 0; i < gameIds.length; ++i) {
const matchSaved = await summonerDB.matches().where({ gameId: gameIds[i] }).first()
if (matchSaved) {
console.log('match in mongodb')
matchesDetails.push(matchSaved)
} else {
console.log('match to get from api')
matchesToGetFromRiot.push(gameIds[i])
}
}
@ -122,13 +120,13 @@ class MatchService {
await BasicMatchTransformer.transform(matchesFromApi, ctx)
Logger.transport('file').info(matchesFromApi)
matchesDetails = [...matchesDetails, ...matchesFromApi]
/* Save all matches from Riot Api in db */
for (const match of matchesFromApi) {
await summonerDB.matches().create(match)
console.log('match saved')
match.newMatch = true
}
console.log('matches saved in db')
matchesDetails = [...matchesDetails, ...matchesFromApi]
}
/* Sort matches */