From 5cd58d4119ff267b344f868fb99685730306889a Mon Sep 17 00:00:00 2001 From: Sabe Jones Date: Mon, 22 Apr 2024 17:52:07 -0500 Subject: [PATCH 1/3] WIP(shops): dates and fixes --- website/client/src/components/header/userDropdown.vue | 6 +----- website/client/src/components/ui/selectList.vue | 2 +- website/common/script/content/constants/schedule.js | 7 ++++--- website/common/script/libs/getItemInfo.js | 2 +- website/common/script/libs/shops.js | 1 + 5 files changed, 8 insertions(+), 10 deletions(-) diff --git a/website/client/src/components/header/userDropdown.vue b/website/client/src/components/header/userDropdown.vue index 46dba369d3..f149222731 100644 --- a/website/client/src/components/header/userDropdown.vue +++ b/website/client/src/components/header/userDropdown.vue @@ -35,13 +35,9 @@ /> {{ $t('editAvatar') }} - {{ $t('backgrounds') }} Date: Tue, 23 Apr 2024 14:40:10 +0200 Subject: [PATCH 2/3] Fix assigning end date to content schedule items --- .../common/script/content/constants/schedule.js | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/website/common/script/content/constants/schedule.js b/website/common/script/content/constants/schedule.js index 1c2fcdcb9d..1bd03b32e8 100644 --- a/website/common/script/content/constants/schedule.js +++ b/website/common/script/content/constants/schedule.js @@ -839,16 +839,24 @@ export function getScheduleMatchingGroup (type, date) { const checkedDate = date || new Date(); if (cacheDate !== null && (getDay(checkedDate) !== getDay(cacheDate) || getMonth(checkedDate) !== getMonth(cacheDate))) { + // Clear cached matchers, since they are old cacheDate = null; cachedScheduleMatchers = null; } if (!cachedScheduleMatchers) { + // No matchers exist, make new ones cacheDate = new Date(); cachedScheduleMatchers = {}; assembleScheduledMatchers(checkedDate).forEach(matcher => { if (!cachedScheduleMatchers[matcher.type]) { cachedScheduleMatchers[matcher.type] = makeMatcherClass(); } + const end = moment(checkedDate); + end.date(TYPE_SCHEDULE[type]); + if (end.date() <= moment(checkedDate).date()) { + moment(end).add(1, 'months'); + } + cachedScheduleMatchers[matcher.type].end = end.toDate(); if (matcher.matcher instanceof Function) { cachedScheduleMatchers[matcher.type].matchers.push(matcher.matcher); } else if (matcher.items instanceof Array) { @@ -857,13 +865,8 @@ export function getScheduleMatchingGroup (type, date) { }); } if (!cachedScheduleMatchers[type]) { - let end = moment(checkedDate); - end.date(TYPE_SCHEDULE[type]); - if (end.date() <= moment(checkedDate).date()) { - moment(end).add(1, 'months'); - } + // No matchers exist for this type return { - end: end.toDate(), items: [], match () { return true; From 8df326bf92db0552fce44cc34d9507675ba2e058 Mon Sep 17 00:00:00 2001 From: Sabe Jones Date: Tue, 23 Apr 2024 10:50:45 -0500 Subject: [PATCH 3/3] WIP(shop): add timings to categories --- website/common/script/content/constants/schedule.js | 8 ++++---- website/common/script/libs/getItemInfo.js | 4 +++- website/common/script/libs/shops.js | 2 ++ 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/website/common/script/content/constants/schedule.js b/website/common/script/content/constants/schedule.js index 1bd03b32e8..6ef022ebce 100644 --- a/website/common/script/content/constants/schedule.js +++ b/website/common/script/content/constants/schedule.js @@ -24,7 +24,7 @@ function inListMatcher (list) { }; } -const ALWAYS_AVAILABLE_CUSTOMIZATIONS = [ +export const ALWAYS_AVAILABLE_CUSTOMIZATIONS = [ 'animalSkins', 'rainbowSkins', 'rainbowHairColors', @@ -851,11 +851,11 @@ export function getScheduleMatchingGroup (type, date) { if (!cachedScheduleMatchers[matcher.type]) { cachedScheduleMatchers[matcher.type] = makeMatcherClass(); } - const end = moment(checkedDate); + let end = moment(checkedDate); end.date(TYPE_SCHEDULE[type]); if (end.date() <= moment(checkedDate).date()) { - moment(end).add(1, 'months'); - } + end = moment(end).add(1, 'months'); + } cachedScheduleMatchers[matcher.type].end = end.toDate(); if (matcher.matcher instanceof Function) { cachedScheduleMatchers[matcher.type].matchers.push(matcher.matcher); diff --git a/website/common/script/libs/getItemInfo.js b/website/common/script/libs/getItemInfo.js index af72e71d01..4e75823eef 100644 --- a/website/common/script/libs/getItemInfo.js +++ b/website/common/script/libs/getItemInfo.js @@ -8,6 +8,8 @@ import isPinned from './isPinned'; import isFreeRebirth from './isFreeRebirth'; import getOfficialPinnedItems from './getOfficialPinnedItems'; +import { ALWAYS_AVAILABLE_CUSTOMIZATIONS } from '../content/constants/schedule'; + function lockQuest (quest, user) { // checks series quests, including Masterclasser if (quest.prereqQuests) { @@ -490,7 +492,7 @@ export default function getItemInfo (user, type, item, officialPinnedItems, lang throw new BadRequest(i18n.t('wrongItemType', { type }, language)); } - if (matcher) { + if (matcher && (!itemInfo.set || ALWAYS_AVAILABLE_CUSTOMIZATIONS.indexOf(itemInfo.set.key) === -1)) { itemInfo.end = matcher.end; } diff --git a/website/common/script/libs/shops.js b/website/common/script/libs/shops.js index ab5ae85c20..a1be27efba 100644 --- a/website/common/script/libs/shops.js +++ b/website/common/script/libs/shops.js @@ -618,6 +618,7 @@ shops.getCustomizationsShopCategories = function getCustomizationsShopCategories hairStyle, officialPinnedItems, language, + hairType === 'color' ? customizationMatcher : null, ); category.items.push(item); } @@ -643,6 +644,7 @@ shops.getCustomizationsShopCategories = function getCustomizationsShopCategories appearance, officialPinnedItems, language, + type === 'skin' ? customizationMatcher : null, ); category.items.push(item); }