traxxx/assets/components/home/home.vue

60 lines
1.4 KiB
Vue
Raw Normal View History

<template>
<div class="content">
<FilterBar :fetch-releases="fetchReleases" />
<div class="content-inner">
2020-02-26 00:15:50 +00:00
<Releases :releases="releases" />
</div>
</div>
</template>
<script>
import FilterBar from '../header/filter-bar.vue';
import Releases from '../releases/releases.vue';
2019-09-10 14:48:04 +00:00
async function fetchReleases() {
2020-02-26 00:15:50 +00:00
this.releases = await this.$store.dispatch('fetchReleases', { limit: 20 });
this.$store.commit('setCache', {
target: 'home',
releases: this.releases,
});
}
async function mounted() {
this.pageTitle = '';
await this.fetchReleases();
}
function updated() {
if (this.from.name === 'scene' && this.from.hash === '#home') {
const releaseTile = document.querySelector(`#scene-${this.from.params.releaseId}`);
if (releaseTile) releaseTile.scrollIntoView();
}
}
export default {
components: {
FilterBar,
Releases,
},
data() {
return {
// releases: this.$store.state.releases.cache.home || [], // slows down apparent page load
releases: [],
networks: [],
pageTitle: null,
from: null,
};
},
beforeRouteEnter(to, from, next) {
next(vm => vm.$set(vm, 'from', from));
},
updated,
mounted,
methods: {
fetchReleases,
},
};
</script>