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 primarily serves to ensure that Quick Tags has no side effects. Makes sense to do anyway, though, I think.
Does this need default values to handle missing data?
Description
As proposed in #838, this creates a utility function that encapsulates the logic for, "I want to edit a post using the NPF API endpoints; what do I start with so that I don't change anything besides what I want to change?" It takes the JSON response from the
/posts/{post-id}
GET request, removes irrelevant fields, and applies a few transformations, which Quick Tags and Trim Reblogs both had implemented separately.It ensures that there is one place to add future properties that should be passed through or future transformations that should be added.
The functional change here is passing through
can_be_tipped
(which is necessary) andhas_community_label
, andcommunity_label_categories
(which do not seem necessary).For discussion: According to my testing, the list of passed-through properties could actually be shorter; for example,
source_url
is optional; should this err on the side of passing the maximum amount of data in case the Tumblr backend is ever changed, or the minimum amount to save network bytes?Also, note that this relies on the snake_case conversion in apiFetch. Keeping everything as camelCase for as long as possible is the least confusing, IMO.
Testing steps
Also, test Trim Reblogs to ensure it functions normally; it should be no different than before.