mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-14 05:07:22 +01:00
simplify schedule matching usage
This commit is contained in:
committed by
Sabe Jones
parent
129cb7627c
commit
736ef16430
@@ -7,7 +7,7 @@ import { removeItemByPath } from './pinnedGearUtils';
|
||||
import getItemInfo from '../libs/getItemInfo';
|
||||
import content from '../content/index';
|
||||
import updateUserBalance from './updateUserBalance';
|
||||
import { assembleScheduledMatchers } from '../content/constants/schedule';
|
||||
import { getScheduleMatchingGroup } from '../content/constants/schedule';
|
||||
|
||||
const incentiveBackgrounds = ['blue', 'green', 'red', 'purple', 'yellow'];
|
||||
|
||||
@@ -225,12 +225,8 @@ export default async function unlock (user, req = {}, analytics) {
|
||||
const { set, items, paths } = getSet(setType, firstPath, req);
|
||||
|
||||
if (isBackground) {
|
||||
const matchers = assembleScheduledMatchers(new Date())
|
||||
.filter(matcher => matcher.type === 'backgrounds')
|
||||
.map(matcher => matcher.matcher);
|
||||
const isAvailable = matchers.map(matcher => matcher(set.key))
|
||||
.every(matcher => matcher === true);
|
||||
if (!isAvailable) {
|
||||
const matchers = getScheduleMatchingGroup('backgrounds');
|
||||
if (!matchers.match(set.key)) {
|
||||
throw new NotAuthorized(i18n.t('notAvailable', req.language));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user