mirror of
https://github.com/sudoxnym/habitica.git
synced 2026-07-15 00:12:17 +00:00
fix(shops): show correct countdown outside of Gala
This commit is contained in:
parent
04e2a39a9f
commit
91cbf7a2a9
2 changed files with 3 additions and 53 deletions
|
|
@ -385,7 +385,6 @@ import EquipmentAttributesGrid from '../inventory/equipment/attributesGrid.vue';
|
||||||
import Item from '@/components/inventory/item';
|
import Item from '@/components/inventory/item';
|
||||||
import Avatar from '@/components/avatar';
|
import Avatar from '@/components/avatar';
|
||||||
|
|
||||||
import seasonalShopConfig from '@/../../common/script/libs/shops-seasonal.config';
|
|
||||||
import { drops as dropEggs } from '@/../../common/script/content/eggs';
|
import { drops as dropEggs } from '@/../../common/script/content/eggs';
|
||||||
import { drops as dropPotions } from '@/../../common/script/content/hatching-potions';
|
import { drops as dropPotions } from '@/../../common/script/content/hatching-potions';
|
||||||
|
|
||||||
|
|
@ -438,7 +437,6 @@ export default {
|
||||||
|
|
||||||
selectedAmountToBuy: 1,
|
selectedAmountToBuy: 1,
|
||||||
isPinned: false,
|
isPinned: false,
|
||||||
endDate: seasonalShopConfig.dateRange.end,
|
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
|
|
@ -489,6 +487,9 @@ export default {
|
||||||
nonSubscriberHourglasses () {
|
nonSubscriberHourglasses () {
|
||||||
return (!this.user.purchased.plan.customerId && !this.user.purchased.plan.consecutive.trinkets && this.getPriceClass() === 'hourglasses');
|
return (!this.user.purchased.plan.customerId && !this.user.purchased.plan.consecutive.trinkets && this.getPriceClass() === 'hourglasses');
|
||||||
},
|
},
|
||||||
|
endDate () {
|
||||||
|
return moment(this.item.event.end);
|
||||||
|
},
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
item: function itemChanged () {
|
item: function itemChanged () {
|
||||||
|
|
|
||||||
|
|
@ -8,16 +8,6 @@
|
||||||
:popover-position="'top'"
|
:popover-position="'top'"
|
||||||
@click="itemSelected(item)"
|
@click="itemSelected(item)"
|
||||||
>
|
>
|
||||||
<span slot="popoverContent">
|
|
||||||
<strong v-if="item.key === 'gem' && gemsLeft === 0">{{ $t('maxBuyGems') }}</strong>
|
|
||||||
<h4 class="popover-content-title">{{ item.text }}</h4>
|
|
||||||
<div
|
|
||||||
v-if="item.event"
|
|
||||||
class="mt-2"
|
|
||||||
>
|
|
||||||
{{ limitedString }}
|
|
||||||
</div>
|
|
||||||
</span>
|
|
||||||
<template
|
<template
|
||||||
slot="itemBadge"
|
slot="itemBadge"
|
||||||
slot-scope="ctx"
|
slot-scope="ctx"
|
||||||
|
|
@ -32,11 +22,9 @@
|
||||||
import _filter from 'lodash/filter';
|
import _filter from 'lodash/filter';
|
||||||
import _sortBy from 'lodash/sortBy';
|
import _sortBy from 'lodash/sortBy';
|
||||||
import _map from 'lodash/map';
|
import _map from 'lodash/map';
|
||||||
import moment from 'moment';
|
|
||||||
import { mapState } from '@/libs/store';
|
import { mapState } from '@/libs/store';
|
||||||
import pinUtils from '@/mixins/pinUtils';
|
import pinUtils from '@/mixins/pinUtils';
|
||||||
import planGemLimits from '@/../../common/script/libs/planGemLimits';
|
import planGemLimits from '@/../../common/script/libs/planGemLimits';
|
||||||
import seasonalShopConfig from '@/../../common/script/libs/shops-seasonal.config';
|
|
||||||
|
|
||||||
import ShopItem from '../shopItem';
|
import ShopItem from '../shopItem';
|
||||||
import CategoryItem from './categoryItem';
|
import CategoryItem from './categoryItem';
|
||||||
|
|
@ -48,12 +36,6 @@ export default {
|
||||||
},
|
},
|
||||||
mixins: [pinUtils],
|
mixins: [pinUtils],
|
||||||
props: ['hideLocked', 'hidePinned', 'searchBy', 'sortBy', 'category'],
|
props: ['hideLocked', 'hidePinned', 'searchBy', 'sortBy', 'category'],
|
||||||
data () {
|
|
||||||
return {
|
|
||||||
timer: '',
|
|
||||||
limitedString: '',
|
|
||||||
};
|
|
||||||
},
|
|
||||||
computed: {
|
computed: {
|
||||||
...mapState({
|
...mapState({
|
||||||
content: 'content',
|
content: 'content',
|
||||||
|
|
@ -106,43 +88,10 @@ export default {
|
||||||
return result;
|
return result;
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
mounted () {
|
|
||||||
this.countdownString();
|
|
||||||
this.timer = setInterval(this.countdownString, 1000);
|
|
||||||
},
|
|
||||||
beforeDestroy () {
|
|
||||||
this.cancelAutoUpdate();
|
|
||||||
},
|
|
||||||
methods: {
|
methods: {
|
||||||
itemSelected (item) {
|
itemSelected (item) {
|
||||||
this.$root.$emit('buyModal::showItem', item);
|
this.$root.$emit('buyModal::showItem', item);
|
||||||
},
|
},
|
||||||
countdownString () {
|
|
||||||
const diffDuration = moment.duration(moment(seasonalShopConfig.dateRange.end).diff(moment()));
|
|
||||||
|
|
||||||
if (diffDuration.asSeconds() <= 0) {
|
|
||||||
this.limitedString = this.$t('noLongerAvailable');
|
|
||||||
} else if (diffDuration.days() > 0 || diffDuration.months() > 0) {
|
|
||||||
this.limitedString = this.$t('limitedAvailabilityDays', {
|
|
||||||
days: moment(seasonalShopConfig.dateRange.end).diff(moment(), 'days'),
|
|
||||||
hours: diffDuration.hours(),
|
|
||||||
minutes: diffDuration.minutes(),
|
|
||||||
});
|
|
||||||
} else if (diffDuration.asMinutes() > 2) {
|
|
||||||
this.limitedString = this.$t('limitedAvailabilityHours', {
|
|
||||||
hours: diffDuration.hours(),
|
|
||||||
minutes: diffDuration.minutes(),
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
this.limitedString = this.$t('limitedAvailabilityMinutes', {
|
|
||||||
minutes: diffDuration.minutes(),
|
|
||||||
seconds: diffDuration.seconds(),
|
|
||||||
});
|
|
||||||
}
|
|
||||||
},
|
|
||||||
cancelAutoUpdate () {
|
|
||||||
clearInterval(this.timer);
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue