🐛 Bug Report: Default post sort does not apply until settings are saved at least once
Describe the bug
When an instance (like my private one) is configured to sort posts (and possibly comments - I didn't test this) by anything other than the default (Hot for subreddit posts), the new setting doesn't take effect until the Settings page is opened and "Save" is clicked at least once (even if none of the settings were changed).
Steps to reproduce the bug
Steps to reproduce the behavior:
0. Configure your Redlib instance to sort posts by anything other than "Hot" (using REDLIB_DEFAULT_POST_SORT in my case), and restart it.
- Visit any subreddit through your instance (the default
r/popularpage is fine). - Notice that posts are sorted by "Hot" instead of your default setting (I use "New" on my instance).
- Go to the settings page. Notice the default subreddit post sort is set to your new default.
- Click "Save" at the bottom of the page. No need to change any settings.
- Go back to the previous page and refresh (to apply settings "changes").
What's the expected behavior?
Subreddit posts will always be sorted by your instance's chosen default setting, even without saving any settings on the client end.
Additional context / screenshot
r/popular in a new browser session (all cookies/cache cleared):
Relevant instance info, after showing the previous page:
Relevant Redlib settings, after showing instance info:
- [x] I checked that the instance that this was reported on is running the latest git commit, or I can reproduce it locally on the latest git commit
Instance is running commit 2dc6b5f (latest as of writing).
Same issue here.
Same issue here.
I have created a patch for this bug (in PR #521). Doing some further digging, the bug appears to have existed since configuration via environment variables was first introduced in this commit. Might explain why so many Redlib instances I used before I made my own seemingly had the default sort set to "Hot".