Skip to content

Commit

Permalink
🐛 Display all crates in the sidebar (closes #39)
Browse files Browse the repository at this point in the history
Previously it would only get a max of 20 crates from the API
  • Loading branch information
BetaHuhn committed Sep 16, 2021
1 parent 1d7c7f8 commit facd658
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion client/layouts/sidebar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export default {
if (!this.isPublic) {
this.loadingCrates = true
this.$store.dispatch('GET_CRATES').then(() => {
this.$store.dispatch('GET_CRATES', 0).then(() => {
setTimeout(() => {
this.loadingCrates = false
}, 500)
Expand Down
2 changes: 1 addition & 1 deletion client/pages/welcome.vue
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ export default {
}
},
async fetch() {
this.$store.dispatch('GET_CRATES')
this.$store.dispatch('GET_CRATES', 5)
const links = await this.$api.getRecentLinks()
this.$store.commit('SET_CURRENT_CRATE_LINKS', links)
Expand Down
4 changes: 2 additions & 2 deletions client/plugins/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,10 @@ class API {
return res.data
}

async getCrates() {
async getCrates(limit = 20) {
if (this.publicMode) return undefined

const { data: res } = await this.http.get(`/crate`)
const { data: res } = await this.http.get(`/crate?limit=${ limit }`)

return res.data
}
Expand Down
4 changes: 2 additions & 2 deletions client/store/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,8 @@ export const actions = {

commit('STORE_EXTERNAL_CRATES', crates)
},
async GET_CRATES({ commit }) {
const crates = await this.$api.getCrates()
async GET_CRATES({ commit }, limit) {
const crates = await this.$api.getCrates(limit)

commit('STORE_CRATES', crates)
},
Expand Down

0 comments on commit facd658

Please sign in to comment.