new-xkit / XKit

Fork of XKit, the extension framework for Tumblr
https://new-xkit-extension.tumblr.com
Other
459 stars 135 forks source link

Quick Tags: Prevent breaking non-legacy posts #2106

Closed marcustyphoon closed 3 weeks ago

marcustyphoon commented 1 year ago

This replaces the legacy SVC API endpoint used in Quick Tags with the less-old mass editor endpoint. This prevents posts from being converted to the legacy format and breaking things like polls and preventing XKit Rewritten's Trim Reblogs from working on the edited thread.

The mass editor endpoint seems to work on both legacy and new post formats without side effects, so it's well-suited to maintaining this version of XKit with maximum compatibility.

Do we have a helper function for the modern apiFetch? I didn't see one, so I left in the legacy XKit.interface.fetch call to get the current post tags.

I cannot believe this took me two hours. Most of it was reading xkit_patches, which, you know. What do you expect, I guess.

Resolves #2105.

AprilSylph commented 1 year ago

did you test this? both modes working correctly?

marcustyphoon commented 1 year ago

I just went to test this again and form_key is busted on first install until you load tumblr.com/about. great codebase.

marcustyphoon commented 1 year ago

Well that was a goddamn nightmare. Note to self: don't even PR the one that uses XKit.interface.fetch next time.

did you test this?

Now I have.

Edit from later: My testing was inadequate. Now I have.

Uh. Maybe we should go conscript an XKit 7 devotee to go test my PRs on this repo.

AprilSylph commented 1 month ago

I can't get New XKit's Quick Tags to work at all (fresh install on Firefox). Does this still need reviewing?

marcustyphoon commented 1 month ago

Oh, really? It works for me on my main browser profile. I wonder if the form key fetch broke again... but then, that wouldn't prevent the button from showing up? Hm.

marcustyphoon commented 1 month ago

Oh, for the love of—I think sinceXKit.interface.fetch doesn't use XKit.interface.async_form_key, it will fail unless you navigate once to a legacy page or use one of the features that does use it.

https://github.com/new-xkit/XKit/blob/d00391097fdc06b87910252a929921a2ec81fd22/xkit.js#L2452-L2460

edit: oh hah I commented on that above apparently

marcustyphoon commented 1 month ago

Oh, for the love of—I think sinceXKit.interface.fetch doesn't use XKit.interface.async_form_key, it will fail unless you navigate once to a legacy page or use one of the features that does use it.

actually I don't know why this is? XKit.interface.async_form_key gets called and it looks up to date.

edit: that code is in this PR what the fuck am I doing