Applying any date or datetime filters will cause the whole table page to crash, and the crash persists until user manually visit debug page and reset filters.
We expect toDate to be present in the filter value because it is supposed to be a Firestore Timestamp object.
const filterDate =
"toDate" in filter.value ? filter.value.toDate() : filter.value;
This used to hold true, however, the recent shareable filter url feature slightly changed the way filters are passed - it uses JSON.stringify on filters and set it in the url. When the values are parsed, we no longer get Timestamp. Instead, we get { nanoseconds: number; seconds: number }, the Timestamp object without toDate() method. The above code would no longer work, causing the table page to crash.
Fix
Without changing how the shareable filter url works, adding a parser on the date values would fix the issue.
...
if (date.seconds) {
return new Date(date.seconds * 1000 + date.nanoseconds / 1_000_000);
...
An alternative way to fix the issue is to make use of toDate() method of Timestamp with the filter values in the url, however I think this will introduce more lines of code and complexity, and the parser solution would be simpler.
Issue
Applying any date or datetime filters will cause the whole table page to crash, and the crash persists until user manually visit debug page and reset filters.
Example: https://github.com/rowyio/rowy/discussions/1513
Cause
We expect
toDate
to be present in the filter value because it is supposed to be a FirestoreTimestamp
object.This used to hold true, however, the recent shareable filter url feature slightly changed the way filters are passed - it uses
JSON.stringify
on filters and set it in the url. When the values are parsed, we no longer getTimestamp
. Instead, we get{ nanoseconds: number; seconds: number }
, the Timestamp object withouttoDate()
method. The above code would no longer work, causing the table page to crash.Fix
Without changing how the shareable filter url works, adding a parser on the date values would fix the issue.
An alternative way to fix the issue is to make use of
toDate()
method ofTimestamp
with the filter values in the url, however I think this will introduce more lines of code and complexity, and the parser solution would be simpler.