mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-17 06:37:23 +01:00
Squashed commit of the following:
commitbde71cc45dAuthor: Kalista Payne <sabrecat@gmail.com> Date: Thu Mar 20 15:25:11 2025 -0500 fix(potions): add missing Cryptid release date commit1a50413402Author: Kalista Payne <sabrecat@gmail.com> Date: Tue Mar 18 16:52:19 2025 -0500 fix(wacky): revise text, address linting commit2d49a16f55Author: Phillip Thelen <phillip@habitica.com> Date: Tue Mar 18 16:05:17 2025 +0100 Fix displaying countdown for recurring event items commitcf20b30975Author: Kalista Payne <sabrecat@gmail.com> Date: Fri Mar 14 18:01:37 2025 -0500 fix(lint): line length commite39e490e41Author: Kalista Payne <sabrecat@gmail.com> Date: Fri Mar 14 17:55:12 2025 -0500 fix(foolin): correct animation and end date of potions commit164e2eefddAuthor: Kalista Payne <sabrecat@gmail.com> Date: Thu Mar 13 17:25:14 2025 -0500 fix(event): Panda Cub typo, shift start date commit394c922287Author: Kalista Payne <sabrecat@gmail.com> Date: Thu Mar 13 17:02:12 2025 -0500 fix(test): account for addition of Cryptid commitbea9e40338Author: Kalista Payne <sabrecat@gmail.com> Date: Thu Mar 13 16:52:37 2025 -0500 feat(event): April Fools 2025
This commit is contained in:
@@ -841,6 +841,30 @@ function getGalaIndex (date) {
|
||||
return parseInt((galaCount / 12) * galaMonth, 10);
|
||||
}
|
||||
|
||||
function makeEndDate (checkedDate, matcher) {
|
||||
let end = moment.utc(checkedDate);
|
||||
end.hour(SWITCHOVER_TIME);
|
||||
end.minute(0);
|
||||
end.second(0);
|
||||
if (matcher.end !== undefined) {
|
||||
end.date(matcher.end.getDate());
|
||||
end.month(matcher.end.getMonth());
|
||||
} else {
|
||||
end.date(TYPE_SCHEDULE[matcher.type]);
|
||||
if (matcher.endMonth !== undefined) {
|
||||
if (matcher.startMonth
|
||||
&& matcher.startMonth > matcher.endMonth
|
||||
&& checkedDate.getMonth() > matcher.endMonth) {
|
||||
end.year(checkedDate.getFullYear() + 1);
|
||||
}
|
||||
end.month(matcher.endMonth);
|
||||
} else if (end.valueOf() <= checkedDate.getTime()) {
|
||||
end = moment(end).add(1, 'months');
|
||||
}
|
||||
}
|
||||
return end.toDate();
|
||||
}
|
||||
|
||||
export function assembleScheduledMatchers (date) {
|
||||
const items = [];
|
||||
const month = getMonth(date);
|
||||
@@ -865,7 +889,14 @@ export function assembleScheduledMatchers (date) {
|
||||
items.push(...galaMatchers);
|
||||
getRepeatingEvents(date).forEach(event => {
|
||||
if (event.content) {
|
||||
items.push(...event.content);
|
||||
const { content } = event;
|
||||
const end = makeEndDate(date, event);
|
||||
const m = content.map(matcher => {
|
||||
const newMatcher = { ...matcher };
|
||||
newMatcher.end = end;
|
||||
return newMatcher;
|
||||
});
|
||||
items.push(...m);
|
||||
}
|
||||
});
|
||||
return items;
|
||||
@@ -878,8 +909,15 @@ function makeMatcherClass (date) {
|
||||
return {
|
||||
matchers: [],
|
||||
end: new Date(),
|
||||
specialEnds: {},
|
||||
items: [],
|
||||
matchingDate: date,
|
||||
getEnd (key) {
|
||||
if (this.specialEnds[key]) {
|
||||
return this.specialEnds[key];
|
||||
}
|
||||
return this.end;
|
||||
},
|
||||
match (key) {
|
||||
if (this.matchers.length === 0) {
|
||||
if (this.items.length > 0) {
|
||||
@@ -896,25 +934,6 @@ function makeMatcherClass (date) {
|
||||
};
|
||||
}
|
||||
|
||||
function makeEndDate (checkedDate, matcher) {
|
||||
let end = moment.utc(checkedDate);
|
||||
end.date(TYPE_SCHEDULE[matcher.type]);
|
||||
end.hour(SWITCHOVER_TIME);
|
||||
end.minute(0);
|
||||
end.second(0);
|
||||
if (matcher.endMonth !== undefined) {
|
||||
if (matcher.startMonth
|
||||
&& matcher.startMonth > matcher.endMonth
|
||||
&& checkedDate.getMonth() > matcher.endMonth) {
|
||||
end.year(checkedDate.getFullYear() + 1);
|
||||
}
|
||||
end.month(matcher.endMonth);
|
||||
} else if (end.valueOf() <= checkedDate.getTime()) {
|
||||
end = moment(end).add(1, 'months');
|
||||
}
|
||||
return end.toDate();
|
||||
}
|
||||
|
||||
export function clearCachedMatchers () {
|
||||
cacheDate = null;
|
||||
cachedScheduleMatchers = null;
|
||||
@@ -939,11 +958,19 @@ export function getAllScheduleMatchingGroups (date) {
|
||||
if (!cachedScheduleMatchers[matcher.type]) {
|
||||
cachedScheduleMatchers[matcher.type] = makeMatcherClass(adjustedDate);
|
||||
}
|
||||
cachedScheduleMatchers[matcher.type].end = makeEndDate(checkedDate, matcher);
|
||||
if (matcher.end === undefined) {
|
||||
// we want the default end date to be for matcher type
|
||||
cachedScheduleMatchers[matcher.type].end = makeEndDate(checkedDate, matcher);
|
||||
}
|
||||
if (matcher.matcher instanceof Function) {
|
||||
cachedScheduleMatchers[matcher.type].matchers.push(matcher.matcher);
|
||||
} else if (matcher.items instanceof Array) {
|
||||
cachedScheduleMatchers[matcher.type].items.push(...matcher.items);
|
||||
if (matcher.end !== undefined) {
|
||||
matcher.items.forEach(item => {
|
||||
cachedScheduleMatchers[matcher.type].specialEnds[item] = matcher.end;
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user