Skip to content

DEV: Use cookie instead of URL param to show original content #273

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

Merged
merged 3 commits into from
Apr 14, 2025

Conversation

nattsw
Copy link
Contributor

@nattsw nattsw commented Apr 11, 2025

Currently when the "Show Original" button on the right side of the page is clicked, we append the param ?show=original and trigger a refresh to show the original user-written post content.

Screenshot 2025-04-11 at 5 31 06 PM

With this PR, we will be using cookies (discourse-translator-show-original) instead. This cookie is applied site-wide, not per-topic.

Screenshot 2025-04-11 at 5 34 32 PM

@nattsw nattsw force-pushed the show-original-w- branch from aafb500 to 84323cc Compare April 11, 2025 09:36
@davidtaylorhq
Copy link
Member

To avoid cache poisoning, this cookie will need to be added to the AnonymousCache middleware key. (I think there's a plugin API for that?)

@nattsw nattsw requested review from davidtaylorhq and removed request for davidtaylorhq April 11, 2025 10:39
}
window.location.search = params.toString();

window.location.reload();
Copy link
Member

Choose a reason for hiding this comment

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

Random thought... would calling .refresh() on the Ember router service be enough here? In theory that should re-run all model() hooks on routes? Might be a smoother experience than a full page reload?

Copy link
Contributor Author

@nattsw nattsw Apr 14, 2025

Choose a reason for hiding this comment

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

You are right - weirdly, I included the router already but hadn't called refresh. This is a much better experience ✨

@nattsw nattsw merged commit 2c05a85 into main Apr 14, 2025
6 checks passed
@nattsw nattsw deleted the show-original-w-🍪 branch April 14, 2025 09:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants