Track links and embeds in the composer reducer #5593
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.
This adds tracking of remaining embed/media types to the composer reducer.
They're not being used for anything yet, but you should roughly expect their state to mirror how the composer works today. (There are also some improvements. For example, pasting a quote link after a regular link will correctly mark a quote in the reducer state, whereas the old composer logic was not able to handle that.)
In future PRs, I will be making this the source of truth for two things:
However we're missing some pieces to be able to do that, so for now it's not connected yet.
Note that in the draft, we don't distinguish between different types of links (other than quote/other distinction). This is because they're only relevant for preview and for posting. They're not important in the draft data model because the reducer behavior ("which field gets replaced by which field in which cases") doesn't care about the contents of the link beyond that.
Test Plan
Add
console.log(composerState)
toComposer.tsx
. Verify thecomposerState.embed
fields evolve as you'd expect when you add GIF, add/remove media, paste links, remove GIF, remove links, etc.