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
1 changed files with 28 additions and 16 deletions

View File

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