Skip to content

Commit 97a1089

Browse files
authored
fix: Handle date clearing in Activity view (#554)
Fixes ActivityWatch/activitywatch#1023
1 parent 400ba07 commit 97a1089

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/views/activity/Activity.vue

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -386,16 +386,21 @@ export default {
386386
periodLength = this.periodLength;
387387
}
388388
389+
const momentJsDate = moment(date);
390+
if (!momentJsDate.isValid()) {
391+
return;
392+
}
393+
389394
let new_date;
390395
if (periodLength == '7 days') {
391396
periodLength = 'last7d';
392-
new_date = moment(date).add(1, 'days').format('YYYY-MM-DD');
397+
new_date = momentJsDate.add(1, 'days').format('YYYY-MM-DD');
393398
} else if (periodLength == '30 days') {
394399
periodLength = 'last30d';
395-
new_date = moment(date).add(1, 'days').format('YYYY-MM-DD');
400+
new_date = momentJsDate.add(1, 'days').format('YYYY-MM-DD');
396401
} else {
397402
const new_period_length_moment = periodLengthConvertMoment(periodLength);
398-
new_date = moment(date).startOf(new_period_length_moment).format('YYYY-MM-DD');
403+
new_date = momentJsDate.startOf(new_period_length_moment).format('YYYY-MM-DD');
399404
}
400405
const path = `/activity/${this.host}/${periodLength}/${new_date}/${this.subview}/${this.currentViewId}`;
401406
if (this.$route.path !== path) {

0 commit comments

Comments
 (0)