feat(promo): G1G1 2021

Also refactors a number of places on web client to start using event 
list from world state instead of singular currentEvent
This commit is contained in:
SabreCat 2021-12-15 16:20:43 -06:00
parent a1cddcaf17
commit 391a9bd91b
9 changed files with 50 additions and 12 deletions

View file

@ -89,6 +89,7 @@
</style>
<script>
import find from 'lodash/find';
import { mapState } from '@/libs/store';
import BaseBanner from './base';
@ -98,8 +99,11 @@ export default {
},
computed: {
...mapState({
currentEvent: 'worldState.data.currentEvent',
currentEventList: 'worldState.data.currentEventList',
}),
currentEvent () {
return find(this.currentEventList, event => Boolean(event.gemsPromo));
},
eventName () {
return this.currentEvent && this.currentEvent.event;
},

View file

@ -63,6 +63,7 @@
</style>
<script>
import find from 'lodash/find';
import { mapState } from '@/libs/store';
import BaseBanner from './base';
@ -74,8 +75,11 @@ export default {
},
computed: {
...mapState({
currentEvent: 'worldState.data.currentEvent',
currentEventList: 'worldState.data.currentEventList',
}),
currentEvent () {
return find(this.currentEventList, event => Boolean(event.promo));
},
eventName () {
return this.currentEvent && this.currentEvent.event;
},

View file

@ -364,6 +364,7 @@
</style>
<script>
import find from 'lodash/find';
import moment from 'moment';
import { mapState } from '@/libs/store';
import markdown from '@/directives/markdown';
@ -408,8 +409,11 @@ export default {
...mapState({
user: 'user.data',
originalGemsBlocks: 'content.gems',
currentEvent: 'worldState.data.currentEvent',
currentEventList: 'worldState.data.currentEventList',
}),
currentEvent () {
return find(this.currentEventList, event => Boolean(event.gemsPromo) || Boolean(event.promo));
},
eventName () {
return this.currentEvent && this.currentEvent.event;
},

View file

@ -210,6 +210,7 @@
<script>
import debounce from 'lodash/debounce';
import find from 'lodash/find';
import isUUID from 'validator/lib/isUUID';
import { mapState } from '@/libs/store';
import closeIcon from '@/assets/svg/close.svg';
@ -227,8 +228,11 @@ export default {
},
computed: {
...mapState({
currentEvent: 'worldState.data.currentEvent',
currentEventList: 'worldState.data.currentEventList',
}),
currentEvent () {
return find(this.currentEventList, event => Boolean(event.gemsPromo) || Boolean(event.promo));
},
searchCannotSubmit () {
if (this.userSearchTerm.length < 1) return true;
return typeof this.foundUser._id === 'undefined';

View file

@ -111,6 +111,7 @@
</style>
<script>
import find from 'lodash/find';
import { mapState } from '@/libs/store';
import SecondaryMenu from '@/components/secondaryMenu';
import gifts from '@/assets/svg/gifts-vertical.svg';
@ -128,8 +129,11 @@ export default {
},
computed: {
...mapState({
currentEvent: 'worldState.data.currentEvent',
currentEventList: 'worldState.data.currentEventList',
}),
currentEvent () {
return find(this.currentEventList, event => Boolean(event.promo));
},
promo () {
if (!this.currentEvent || !this.currentEvent.promo) return 'none';
return this.currentEvent.promo;

View file

@ -66,6 +66,7 @@
<script>
import debounce from 'lodash/debounce';
import find from 'lodash/find';
import { mapState } from '@/libs/store';
import notification from './notification';
@ -111,8 +112,11 @@ export default {
...mapState({
notificationStore: 'notificationStore',
userSleeping: 'user.data.preferences.sleep',
currentEvent: 'worldState.data.currentEvent',
currentEventList: 'worldState.data.currentEventList',
}),
currentEvent () {
return find(this.currentEventList, event => Boolean(event.gemsPromo) || Boolean(event.promo));
},
isEventActive () {
return Boolean(this.currentEvent?.event);
},

View file

@ -10,8 +10,21 @@ const gemsPromo = {
export const EVENTS = {
noCurrentEvent: {
start: '2021-11-30T20:00-04:00',
end: '2021-12-31T20:00-04:00',
start: '2022-01-06T20:00-05:00',
end: '2022-02-28T20:00-05:00',
season: 'normal',
npcImageSuffix: '',
},
winter2022Promo: {
start: '2021-12-16T08:00-05:00',
end: '2022-01-06T20:00-05:00',
promo: 'g1g1',
season: 'normal',
npcImageSuffix: '',
},
prePromoNoEvent: {
start: '2021-11-28T20:00-05:00',
end: '2021-12-16T08:00-05:00',
season: 'normal',
npcImageSuffix: '',
},

View file

@ -18,7 +18,7 @@ import {
import shared from '../../../common';
import { sendNotification as sendPushNotification } from '../pushNotifications'; // eslint-disable-line import/no-cycle
import calculateSubscriptionTerminationDate from './calculateSubscriptionTerminationDate';
import { getCurrentEvent } from '../worldState'; // eslint-disable-line import/no-cycle
import { getCurrentEventList } from '../worldState'; // eslint-disable-line import/no-cycle
// @TODO: Abstract to shared/constant
const JOINED_GROUP_PLAN = 'joined group plan';
@ -245,8 +245,9 @@ async function createSubscription (data) {
// Only send push notifications if sending to a user other than yourself
if (data.gift.member._id !== data.user._id) {
const currentEvent = getCurrentEvent();
if (currentEvent && currentEvent.promo && currentEvent.promo === 'g1g1') {
const currentEventList = getCurrentEventList();
const currentEvent = _.find(currentEventList, event => Boolean(event.promo));
if (currentEvent && currentEvent.promo === 'g1g1') {
const promoData = {
user: data.user,
gift: {

View file

@ -23,7 +23,7 @@ export function getCurrentEvent () {
const now = moment();
return now.isBetween(event.start, event.end) && Boolean(event.npcImageSuffix);
return now.isBetween(event.start, event.end); // && Boolean(event.npcImageSuffix);
});
if (!currEvtKey) return null;