FIX: use getter and setter for computed properties (#25259)

This commit is contained in:
Arpit Jalan 2024-01-15 15:04:28 +05:30 committed by GitHub
parent 60a4d09f1a
commit d0486a72ac
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -13,21 +13,27 @@ export default Mixin.create({
},
@discourseComputed("period")
startDate(period) {
const fullDay = moment().locale("en").utc().endOf("day");
startDate: {
get(period) {
const fullDay = moment().locale("en").utc().endOf("day");
switch (period) {
case "yearly":
return fullDay.subtract(1, "year").startOf("day");
case "quarterly":
return fullDay.subtract(3, "month").startOf("day");
case "weekly":
return fullDay.subtract(6, "days").startOf("day");
case "monthly":
return fullDay.subtract(1, "month").startOf("day");
default:
return fullDay.subtract(1, "month").startOf("day");
}
switch (period) {
case "yearly":
return fullDay.subtract(1, "year").startOf("day");
case "quarterly":
return fullDay.subtract(3, "month").startOf("day");
case "weekly":
return fullDay.subtract(6, "days").startOf("day");
case "monthly":
return fullDay.subtract(1, "month").startOf("day");
default:
return fullDay.subtract(1, "month").startOf("day");
}
},
set(period) {
return period;
},
},
@discourseComputed()
@ -41,8 +47,14 @@ export default Mixin.create({
},
@discourseComputed()
endDate() {
return moment().locale("en").utc().endOf("day");
endDate: {
get() {
return moment().locale("en").utc().endOf("day");
},
set(endDate) {
return endDate;
},
},
@discourseComputed()