check genericPurchase rejections and show error (#10526)

This commit is contained in:
negue 2018-07-20 22:33:23 +02:00 committed by Sabe Jones
parent 284b2cc413
commit b7a46637d5

View file

@ -1,13 +1,27 @@
export default {
methods: {
makeGenericPurchase (item, type = 'buyModal', quantity = 1) {
this.$store.dispatch('shops:genericPurchase', {
pinType: item.pinType,
type: item.purchaseType,
key: item.key,
currency: item.currency,
quantity,
});
async makeGenericPurchase (item, type = 'buyModal', quantity = 1) {
try {
await this.$store.dispatch('shops:genericPurchase', {
pinType: item.pinType,
type: item.purchaseType,
key: item.key,
currency: item.currency,
quantity,
});
} catch (e) {
if (!e.request) {
// axios request errors already handled by app.vue
this.$store.dispatch('snackbars:add', {
title: '',
text: e.message,
type: 'error',
});
return;
} else {
throw e;
}
}
this.$root.$emit('playSound', 'Reward');