fixed #26 + loaded matches now still loaded after visiting match

This commit is contained in:
2021-10-31 02:51:58 +01:00
committed by Giovanni Harting
parent c346dd13e8
commit 9e8c840024
2 changed files with 128 additions and 45 deletions

View File

@@ -43,11 +43,13 @@
<script> <script>
import {GoToPlayer, SaveLastVisitedToLocalStorage, setTitle} from "../utils"; import {GoToPlayer, SaveLastVisitedToLocalStorage, setTitle} from "../utils";
import {onBeforeMount, ref} from "vue"; import {onBeforeMount, ref} from "vue";
import {useStore} from "vuex";
export default { export default {
name: 'Home', name: 'Home',
setup() { setup() {
setTitle('Home') setTitle('Home')
const store = useStore()
const recentVisited = ref([]) const recentVisited = ref([])
@@ -78,7 +80,10 @@ export default {
loadRecentVisited() loadRecentVisited()
} }
onBeforeMount(() => loadRecentVisited()) onBeforeMount(() => {
loadRecentVisited()
store.commit('resetPlayerDetails')
})
return {recentVisited, GoToPlayer, removeRecentVisited} return {recentVisited, GoToPlayer, removeRecentVisited}
} }

View File

@@ -138,9 +138,11 @@
<tbody> <tbody>
<tr v-for="match in data.matches" <tr v-for="match in data.matches"
:key="match.match_id" :key="match.match_id"
:class="GetWinLoss(match.match_result, match.stats.team_id)" :class="GetWinLoss(match.match_result, match.stats.team_id) + (match.vac || match.game_ban ? ' ban' : '')"
:title="match.vac ? 'VAC-banned player in this game' : match.game_ban ? 'Game-banned player in this game' : ''"
class="match" class="match"
@click="GoToMatch(match.match_id)"> @click="GoToMatch(match.match_id)"
>
<td class="td-map text-center"> <td class="td-map text-center">
<i v-if="match.parsed" class="far fa-chart-bar parsed" style="cursor: help" <i v-if="match.parsed" class="far fa-chart-bar parsed" style="cursor: help"
title="Demo has been parsed for additional data"></i> title="Demo has been parsed for additional data"></i>
@@ -299,7 +301,7 @@
</template> </template>
<script> <script>
import {onBeforeMount, onBeforeUnmount, onMounted, reactive, ref, watch} from "vue"; import {onBeforeMount, onMounted, reactive, ref, watch} from "vue";
import {useStore} from "vuex"; import {useStore} from "vuex";
import { import {
constructAvatarUrl, constructAvatarUrl,
@@ -366,7 +368,7 @@ export default {
} }
) )
const SetPlayerData = () => { const SetPlayerData = async () => {
data.tracked = store.state.playerDetails.tracked data.tracked = store.state.playerDetails.tracked
if (store.state.playerDetails.matches) if (store.state.playerDetails.matches)
data.matches = store.state.playerDetails.matches data.matches = store.state.playerDetails.matches
@@ -387,7 +389,7 @@ export default {
}) })
if (store.state.playerDetails.matches) if (store.state.playerDetails.matches)
LoadImage(data.matches[0].map ? data.matches[0].map : 'random') await LoadImage(data.matches[0].map ? data.matches[0].map : 'random')
let player = { let player = {
'steamid64': store.state.playerDetails.steamid64, 'steamid64': store.state.playerDetails.steamid64,
@@ -406,12 +408,15 @@ export default {
data.playerMeta = await getPlayerMeta(props.id, displayCounter) data.playerMeta = await getPlayerMeta(props.id, displayCounter)
if (res === 200 && resData) { if (res === 200 && resData) {
store.commit({ if (resData.steamid64 !== store.state.playerDetails.steamid64) {
type: 'changePlayerDetails', store.commit('resetPlayerDetails')
data: resData store.commit({
}) type: 'changePlayerDetails',
data: resData
})
}
SetPlayerData() await SetPlayerData()
console.log(store.state.playerDetails) console.log(store.state.playerDetails)
} else { } else {
@@ -517,14 +522,12 @@ export default {
data.best_maps.splice(displayCounter, data.best_maps.length - displayCounter) data.best_maps.splice(displayCounter, data.best_maps.length - displayCounter)
}) })
onBeforeUnmount(() => { onMounted(async () => {
store.commit('resetPlayerDetails')
})
onMounted(() => {
const height = window.innerHeight - NAV_HEIGHT - FOOTER_HEIGHT const height = window.innerHeight - NAV_HEIGHT - FOOTER_HEIGHT
const wrapper = document.querySelector('.wrapper') const wrapper = document.querySelector('.wrapper')
wrapper.style.minHeight = height + 'px' wrapper.style.minHeight = height + 'px'
await GetPlayer()
}) })
return { return {
@@ -658,30 +661,6 @@ export default {
} }
} }
.win {
background: linear-gradient(90deg, rgba(0, 255, 0, .2) 0%, rgba(0, 255, 0, .1) 5%, rgba(20, 20, 20, .8) 15%, rgba(20, 20, 20, .8) 100%);
&:hover {
background: linear-gradient(90deg, rgba(0, 255, 0, .2) 0%, rgba(0, 255, 0, .1) 5%, rgba(30, 30, 30, .9) 15%, rgba(30, 30, 30, .9) 100%);
}
}
.loss {
background: linear-gradient(90deg, rgba(255, 0, 0, 0.2) 0%, rgba(255, 0, 0, 0.1) 5%, rgba(20, 20, 20, .8) 15%, rgba(20, 20, 20, .8) 100%);
&:hover {
background: linear-gradient(90deg, rgba(255, 0, 0, 0.2) 0%, rgba(255, 0, 0, 0.1) 5%, rgba(30, 30, 30, .9) 15%, rgba(30, 30, 30, .9) 100%);
}
}
.draw {
background: linear-gradient(90deg, rgba(255, 255, 0, 0.2) 0%, rgba(255, 255, 0, 0.1) 5%, rgba(20, 20, 20, .8) 15%, rgba(20, 20, 20, .8) 100%);
&:hover {
background: linear-gradient(90deg, rgba(255, 255, 0, 0.2) 0%, rgba(255, 255, 0, 0.1) 5%, rgba(30, 30, 30, .9) 15%, rgba(30, 30, 30, .9) 100%);
}
}
.match-container { .match-container {
display: flex; display: flex;
flex-direction: row; flex-direction: row;
@@ -771,8 +750,8 @@ export default {
.end { .end {
display: flex; display: flex;
width: 45%; width: 45%;
justify-content: end; justify-content: flex-end;
align-items: end; align-items: flex-end;
} }
} }
} }
@@ -851,9 +830,9 @@ table {
.parsed { .parsed {
position: absolute; position: absolute;
left: 7px; left: 7px;
top: 27px; bottom: 23px;
color: var(--bs-warning); color: var(--bs-warning);
font-size: 1.5rem; font-size: 1.7rem;
} }
img { img {
@@ -898,6 +877,106 @@ table {
} }
.match { .match {
$first: rgb(0, 0, 0);
$last: rgb(0, 0, 0);
$win: false;
$loss: false;
$draw: false;
$ban: false;
&.win {
$first: rgb(0, 255, 0);
background: linear-gradient(to right,
rgba($first, 0.2) 0%,
rgba($first, 0.1) 15%,
rgba(0, 0, 0, 0.4) 30%,
rgba(0, 0, 0, 0.4) 70%,
rgba($last, 0.6) 80%,
rgba($last, 0.6) 100%
);
&:hover {
background: linear-gradient(to right,
rgba($first, 0.3) 0%,
rgba($first, 0.2) 15%,
rgba(0, 0, 0, 0.5) 30%,
rgba(0, 0, 0, 0.5) 70%,
rgba($last, 0.7) 80%,
rgba($last, 0.7) 100%
);
}
}
&.draw {
$first: rgb(255, 255, 0);
background: linear-gradient(to right,
rgba($first, 0.2) 0%,
rgba($first, 0.1) 15%,
rgba(0, 0, 0, 0.4) 30%,
rgba(0, 0, 0, 0.4) 70%,
rgba($last, 0.6) 80%,
rgba($last, 0.6) 100%
);
&:hover {
background: linear-gradient(to right,
rgba($first, 0.3) 0%,
rgba($first, 0.2) 15%,
rgba(0, 0, 0, 0.5) 30%,
rgba(0, 0, 0, 0.5) 70%,
rgba($last, 0.7) 80%,
rgba($last, 0.7) 100%
);
}
}
&.loss {
$first: rgb(255, 0, 0);
background: linear-gradient(to right,
rgba($first, 0.2) 0%,
rgba($first, 0.1) 15%,
rgba(0, 0, 0, 0.4) 30%,
rgba(0, 0, 0, 0.4) 70%,
rgba($last, 0.6) 80%,
rgba($last, 0.6) 100%
);
&:hover {
background: linear-gradient(to right,
rgba($first, 0.3) 0%,
rgba($first, 0.2) 15%,
rgba(0, 0, 0, 0.5) 30%,
rgba(0, 0, 0, 0.5) 70%,
rgba($last, 0.7) 80%,
rgba($last, 0.7) 100%
);
}
}
&.ban {
$last: rgb(93, 3, 3);
background: linear-gradient(to right,
rgba($first, 0.2) 0%,
rgba($first, 0.1) 15%,
rgba(0, 0, 0, 0.4) 30%,
rgba(0, 0, 0, 0.4) 70%,
rgba($last, 0.6) 80%,
rgba($last, 0.6) 100%
);
&:hover {
background: linear-gradient(to right,
rgba($first, 0.3) 0%,
rgba($first, 0.2) 15%,
rgba(0, 0, 0, 0.5) 30%,
rgba(0, 0, 0, 0.5) 70%,
rgba($last, 0.7) 80%,
rgba($last, 0.7) 100%
);
}
}
border-bottom: 1px solid rgba(73, 73, 73, 0.73); border-bottom: 1px solid rgba(73, 73, 73, 0.73);
&:last-child { &:last-child {
@@ -908,7 +987,6 @@ table {
cursor: pointer; cursor: pointer;
} }
} }
} }
@media screen and (max-width: 768px) { @media screen and (max-width: 768px) {