fix(search): fix TypeError when extending search range by a week#818
fix(search): fix TypeError when extending search range by a week#818realsudarshan wants to merge 2 commits intoActivityWatch:masterfrom
Conversation
39b800c to
51fbea5
Compare
Greptile SummaryThis PR fixes a
Confidence Score: 5/5The fix is a targeted, self-contained method addition that correctly handles both the moment-object and date-string states of The change is minimal — one new four-line method replaces a broken inline handler. The No files require special attention. Important Files Changed
Sequence DiagramsequenceDiagram
actor User
participant Button as "+1 week Button"
participant addWeek as addWeek()
participant moment as moment.js
participant search as search()
participant API as $aw.query()
User->>Button: click
Button->>addWeek: addWeek()
addWeek->>moment: moment(queryOptions.start, 'YYYY-MM-DD')
moment-->>addWeek: parsed moment object
addWeek->>moment: .subtract(1, 'week').format('YYYY-MM-DD')
moment-->>addWeek: date string
addWeek->>addWeek: "queryOptions.start = date string"
addWeek->>search: search()
search->>moment: moment(queryOptions.start).format()
moment-->>search: ISO timestamp
search->>API: query(timeperiods, query_array)
API-->>search: events[]
search-->>User: display results
Reviews (2): Last reviewed commit: "fix(search): specify format hint to avoi..." | Re-trigger Greptile |
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
|
Closing in favor of #819 which also covers Report and Graph views. Thanks for the thorough fix @TimeToBuildBob! |
Description
Fixes a crash on the Search page that occurred when clicking the "+1 week" button to expand the search scope.
The Problem
.subtract()onstart, which was undefined (it should have beenqueryOptions.start).queryOptions.start, it threw aTypeErrorbecause the date returned by theb-form-datepickeris a formatted string, not amomentobject.The Solution
addWeek()method.queryOptions.startstring into amomentobject, subtracts 1 week, formats it back to'YYYY-MM-DD', and then triggers thesearch()function.Fixes TypeError: Cannot read properties of undefined (reading 'subtract') on Search page #817
fix.mp4