Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create NPF edit parameter utility #879

Merged
merged 4 commits into from
Jan 28, 2023

Conversation

marcustyphoon
Copy link
Collaborator

@marcustyphoon marcustyphoon commented Nov 29, 2022

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) and has_community_label, and community_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

  • Enable tipping on your blog.
  • Load XKit Rewritten without this PR.
  • Set the tipping status on a test post to the opposite of your blog's "Add tip button to your posts by default" preference.
  • Add a tag to the post with Quick Tags. Refresh the page. The tipping status should change to the default.
  • Load XKit Rewritten with this PR.
  • Repeat the above steps. Quick Tags should function and the tipping status should stay as you set it.

Also, test Trim Reblogs to ensure it functions normally; it should be no different than before.

@marcustyphoon

This comment was marked as outdated.

Copy link
Owner

@AprilSylph AprilSylph left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Enabling tipping would be a pain for me, but I can see can_be_tipped: false getting sent in the PUT request for Quick Tags. Trim Reblogs also appears to still work correctly!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants