Fix datetime filters crash table page #1526
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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: #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.