Skip to content

Commit

Permalink
refactor(Home): on mobile, load only the 5 latest prices (instead of …
Browse files Browse the repository at this point in the history
…loading 25 and slicing)
  • Loading branch information
raphodn committed Dec 27, 2024
1 parent 0664d49 commit 4273a2e
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions src/views/Home.vue
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<br>

<v-row>
<v-col v-for="price in displayedPriceList" :key="price" cols="12" sm="6" md="4" xl="3">
<v-col v-for="price in latestPriceList" :key="price" cols="12" sm="6" md="4" xl="3">
<PriceCard :price="price" :product="price.product" elevation="1" height="100%" />
</v-col>
<v-col cols="12" sm="6" md="4" xl="3" align="center">
Expand Down Expand Up @@ -58,12 +58,9 @@ export default {
username() {
return this.appStore.user.username
},
displayedPriceList() {
if (!this.$vuetify.display.smAndUp) {
return this.latestPriceList.slice(0, 5)
} else {
return this.latestPriceList
}
getApiSize() {
if (!this.$vuetify.display.smAndUp) return 5
return 25
}
},
mounted() {
Expand All @@ -73,7 +70,7 @@ export default {
methods: {
getPrices() {
this.loading = true
return api.getPrices({ size: 25 })
return api.getPrices({ size: this.getApiSize })
.then((data) => {
this.latestPriceList = data.items
this.totalPriceCount = data.total
Expand Down

0 comments on commit 4273a2e

Please sign in to comment.