fix(views): use queryOptions.start for +1 week button (closes #817)#819
fix(views): use queryOptions.start for +1 week button (closes #817)#819TimeToBuildBob wants to merge 2 commits intoActivityWatch:masterfrom
Conversation
…yWatch#817) The '+1 week' button on the Search, Report, and Graph views referenced a non-existent top-level `start` data field, throwing `TypeError: Cannot read properties of undefined (reading 'subtract')` when clicked. Replace the inline expression with an `extendByWeek()` method that: - subtracts a week from `queryOptions.start` (the actual data path), and - wraps with `moment()` so it works whether the value is a moment object (initial state) or a date string (after the QueryOptions datepicker emits a string). Reported by @realsudarshan in ActivityWatch#817 with the exact root-cause diagnosis.
Greptile SummaryThis PR fixes a
Confidence Score: 5/5Safe to merge — the change correctly fixes the crash by routing the button click through a properly scoped method in all three views. The fix is minimal and targeted: it replaces three broken inline handlers with a consistent extendByWeek() method that reads the correct data path. The moment() wrapper is already the established pattern in fetchEvents() and search() for handling queryOptions.start, so no new assumptions are introduced. All three files are touched symmetrically with no new side effects. No files require special attention. Important Files Changed
Reviews (2): Last reviewed commit: "style(views): use ES6 method shorthand f..." | Re-trigger Greptile |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #819 +/- ##
=======================================
Coverage 30.76% 30.76%
=======================================
Files 33 33
Lines 1973 1973
Branches 368 368
=======================================
Hits 607 607
+ Misses 1345 1288 -57
- Partials 21 78 +57 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
Thanks for extending the fix to Report and Graph views too — I only caught it in Search. Happy to close my PR #818. |
|
CI is green across all checks and Greptile reviewed as 5/5 safe to merge. Ready for a maintainer to merge when convenient. |
Summary
Fixes the `TypeError: Cannot read properties of undefined (reading 'subtract')` reported in #817 when clicking the +1 week button on the Search page (and also affects the Report and Graph views).
Root cause
The button's inline expression was:
```pug
@click="start = start.subtract(1, 'week'); search()"
```
But `start` is not a top-level data field — it lives at `queryOptions.start`. Clicking the button accessed an undefined identifier and threw immediately. @realsudarshan diagnosed this exactly in the issue.
Fix
Replace the inline expression with an `extendByWeek()` method per affected view:
```js
extendByWeek() {
this.queryOptions.start = moment(this.queryOptions.start).subtract(1, 'week');
this.generate(); // or this.search() in Search.vue
}
```
The extra `moment(...)` wrapper handles the case where `queryOptions.start` was emitted by the QueryOptions datepicker as a `YYYY-MM-DD` string (it would otherwise still throw on subsequent clicks even after fixing the identifier).
Affected views
Verification
Closes #817.