This commit is contained in:
j3d1 2023-05-16 00:43:33 +02:00
parent 34942cedda
commit df70a347e3
2 changed files with 6 additions and 21 deletions

View file

@ -77,7 +77,7 @@
</div>
<div class="card">
<button class="btn" @click="getInventoryItems">Refresh</button>
<button class="btn" @click="fetchInventoryItems">Refresh</button>
<router-link to="/inventory/new" class="btn btn-primary">Add</router-link>
</div>
</div>
@ -110,25 +110,10 @@ export default {
}
},
methods: {
...mapActions(["apiFederatedGet", "getFriends", "getFriendServer"]),
...mapMutations(["setInventoryItems"]),
async getInventoryItems() {
try {
const servers = await this.getFriends().then(friends => friends.map(friend => this.getFriendServer({username: friend})))
const urls = servers.map(server => server.then(s => {
return {host: s, target: "/api/inventory_items/"}
}))
urls.map(url => url.then(u => this.apiFederatedGet(u).then(items => {
this.setInventoryItems({url: u.domain, items})
}).catch(e => {
}))) // TODO: handle error
} catch (e) {
console.error(e)
}
},
...mapActions(["fetchInventoryItems"]),
},
async mounted() {
await this.getInventoryItems()
await this.fetchInventoryItems()
}
}
</script>