Skip to content

fix(ui): Refactor and improve XHR for empathy and post deletion#306

Merged
mrjvs merged 16 commits intodevfrom
patch/3ds-xhr
Jan 28, 2026
Merged

fix(ui): Refactor and improve XHR for empathy and post deletion#306
mrjvs merged 16 commits intodevfrom
patch/3ds-xhr

Conversation

@ashquarky
Copy link
Member

Resolves #XXX

Changes:

Refactors how XHR is handled in the client JS. This was initially intended as a CTR fix for the Cloudflare XSS trip, but the error handling was improved enough to justify porting it to all platforms.

Thankfully, due to the bundler modernising CTR's syntax a lot, it's tolerable to just copy-paste the code between the three, with the only big issue being var/const.

  • Finish setting up TypeScript for the client JS. This includes eslint rules and types for the browser globals.
  • Pull XHR code out into a seperate TypeScript file and modernise it a little (onload works - it's old Chrome, not IE6!)
  • Split empathy and delete API calls into their own functions, a bit reminiscent of the gRPC stuff on the server side. Also improve the error handling for JSON parse errors and others.
    • The delete API doesn't actually return a JSON object from the server - fake it for now, I'll change the server route to be more sensible later.
  • Work around an issue on CTR where only GET and POST requests work. (This is probably related to Nintendo's domain allowlist on this platform)
    • This works with a HTTP header to override the method. Infra: does "smuggling" request methods have security implications, especially via Cloudflare? Can limit to CTR endpoints if it's a problem.
  • Unify the post deletion experience across platforms, with the same texts and error messages.
  • Fix a CSS bug where the toast on web appeared behind the navbar in mobile layout.

This touches the post templates to remove the onclick handlers, so #295 will need equivalent changes to the TSX versions.

The XHR and API files are near-identical between platforms, so a good candidate for a @repo/client-common library. Food for thought.

@ashquarky ashquarky requested a review from mrjvs January 22, 2026 09:27
Copy link
Contributor

@mrjvs mrjvs left a comment

Choose a reason for hiding this comment

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

Tested everything, looks like everything is working. Just a couple review comments.

Also TIL: You can't delete replies on 3ds

@ashquarky ashquarky requested a review from mrjvs January 26, 2026 09:01
Copy link
Contributor

@mrjvs mrjvs left a comment

Choose a reason for hiding this comment

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

Code looks good, I'm waiting on the moderator team to give some feedback on the redirect changes before I approve

mrjvs
mrjvs previously approved these changes Jan 26, 2026
Copy link
Contributor

@mrjvs mrjvs left a comment

Choose a reason for hiding this comment

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

The mod team agreed with this approach, so this is good to merge I think

@ashquarky
Copy link
Member Author

Waiting for #306

@mrjvs
Copy link
Contributor

mrjvs commented Jan 28, 2026

Waiting for #306

Segmentation fault (core dumped)
Process exited with exit code 139

Copy link
Contributor

@mrjvs mrjvs left a comment

Choose a reason for hiding this comment

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

(yes, I am approving my own commits now)

@mrjvs mrjvs merged commit 097000c into dev Jan 28, 2026
10 checks passed
@mrjvs mrjvs deleted the patch/3ds-xhr branch January 28, 2026 11:30
@mrjvs mrjvs mentioned this pull request Jan 28, 2026
@mrjvs mrjvs mentioned this pull request Mar 8, 2026
1 task
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