fix(customizations): responsive updates

This commit is contained in:
Sabe Jones
2024-05-23 17:50:16 -05:00
parent a53a9be4b7
commit 688e7181f0
3 changed files with 32 additions and 17 deletions

View File

@@ -47,6 +47,7 @@
class="new-user" class="new-user"
:member="user" :member="user"
:avatar-only="true" :avatar-only="true"
:override-top-padding="'0px'"
/> />
</div> </div>
<avatar <avatar
@@ -1096,6 +1097,17 @@ export default {
this.monthlyBackgrounds = orderBy(this.monthlyBackgrounds, bg => bg.key, 'desc'); this.monthlyBackgrounds = orderBy(this.monthlyBackgrounds, bg => bg.key, 'desc');
this.standardBackgrounds.splice(0, 0, { key: '', notes: () => this.$t('noBackground') }); this.standardBackgrounds.splice(0, 0, { key: '', notes: () => this.$t('noBackground') });
if (this.editing) this.modalPage = 2; if (this.editing) this.modalPage = 2;
this.$root.$on('buyModal::boughtItem', item => {
if (item.path.includes('background')) {
const newBackground = this.allBackgrounds[item.path.split('.')[2]];
if (newBackground.set === 'timeTravelBackgrounds') {
this.timeTravelBackgrounds.push(newBackground);
} else {
this.monthlyBackgrounds.push(newBackground);
this.monthlyBackgrounds = orderBy(this.monthlyBackgrounds, bg => bg.key, 'desc');
}
}
});
}, },
methods: { methods: {
close () { close () {

View File

@@ -826,6 +826,7 @@ export default {
if (!buySuccess) return; if (!buySuccess) return;
this.sync(); this.sync();
this.$root.$emit('playSound', 'Reward'); this.$root.$emit('playSound', 'Reward');
this.$root.$emit('buyModal::boughtItem', this.item);
this.purchased(this.item.text); this.purchased(this.item.text);
} else { } else {
const shouldConfirmPurchase = this.item.currency === 'gems' || this.item.currency === 'hourglasses'; const shouldConfirmPurchase = this.item.currency === 'gems' || this.item.currency === 'hourglasses';

View File

@@ -130,6 +130,7 @@ export default {
return { return {
searchText: null, searchText: null,
searchTextThrottled: null, searchTextThrottled: null,
unfilteredCategories: [],
viewOptions: {}, viewOptions: {},
}; };
}, },
@@ -148,23 +149,6 @@ export default {
npc: 'url(/static/npc/normal/customizations_npc.png)', npc: 'url(/static/npc/normal/customizations_npc.png)',
}; };
}, },
shop () {
return shops.getCustomizationsShop(this.user);
},
unfilteredCategories () {
const apiCategories = this.shop.categories;
apiCategories.forEach(category => {
// do not reset the viewOptions if already set once
if (typeof this.viewOptions[category.identifier] === 'undefined') {
this.$set(this.viewOptions, category.identifier, {
selected: false,
});
}
});
return apiCategories;
},
categories () { categories () {
const { unfilteredCategories } = this; const { unfilteredCategories } = this;
@@ -183,6 +167,10 @@ export default {
subSection: this.$t('customizations'), subSection: this.$t('customizations'),
section: this.$t('shops'), section: this.$t('shops'),
}); });
this.updateShop();
this.$root.$on('buyModal::boughtItem', () => {
this.updateShop();
});
}, },
methods: { methods: {
customizationsItems (options = {}) { customizationsItems (options = {}) {
@@ -257,6 +245,20 @@ export default {
selectItem (item) { selectItem (item) {
this.$root.$emit('buyModal::showItem', item); this.$root.$emit('buyModal::showItem', item);
}, },
updateShop () {
const shop = shops.getCustomizationsShop(this.user);
shop.categories.forEach(category => {
// do not reset the viewOptions if already set once
if (typeof this.viewOptions[category.identifier] === 'undefined') {
this.$set(this.viewOptions, category.identifier, {
selected: false,
});
}
});
this.unfilteredCategories = shop.categories;
},
}, },
}; };
</script> </script>