[preview] Emit null as snapshot for missing documents #634
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.
This improves how deleted/missing documents are passed through the preview pipeline, and fixes an error that would sometimes be triggered when a previewed document got deleted.
Previously, any preview observer that declared that they would display some fields on some document (e.g.
fieldX
,fieldY
for document with _idabc
) would always receive an object with the given fields no matter if the document existed or not. This made it impossible to tell the difference between a document that was deleted and a document that existed but had missing values for these fields.(One consequence of this was that the reference select input for weak references was displaying "Untitled" after the reference got deleted.)
This fixes this problem by passing on
null
as the snapshot for deleted/missing documents.I've also made sure to avoid calling
preview.prepare
if the preview snapshot isnull
(we may reconsider this, to support overriding the value for Untitled, but that requires some more thoughts I guess)