Add authorId to internal post URL when it is missing #5825
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.
Add authorId to internal post URL when it is missing
Pull Request Type
Description
When you paste a post link into the search bar, we need to make two API requests, this first one is to resolve the URL to figure out the channel ID and the second one is to get the post itself (which needs both the post ID and the channel ID).
This pull request adds the authorId to the in-app post URL after the post has loaded, if it was missing from the URL before. That way if you navigate back to the page again in the future e.g. by pressing the back arrow, we only have to make the API request for the post, as we already know the channel ID.
To avoid the replace action triggering the fetching again when we replace the URL, this pull request only watches the
id
parameter instead of the entire route object.Screenshots
Before:
After:
Testing
window.location.hash
in the devtools, you should be able to see both the post ID and the author IDYou can also check the network tab and check that if you navigate back and forth with the arrows in the navigation bar, it should only call both
/api/v1/resolveurl
and/api/v1/post
the first time, after that it should only call/api/v1/post
.Desktop