Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Checklist
Choose one of the following two options:
Choose one of the following two options:
Pull Request Information
About this Pull Request
This is a simple change to persist across app launches, using AppStorage:
SortingOptions
for the feed andFeedType
(All Posts, Subscribed, etc)Before this PR, each app launch will result in the feed resetting to the default Subscribed feed sorted by Hot. After this PR, the app will remember your last selected
FeedType
andSortingOptions
.Screenshots and Videos
There are no UI changes, it's completely transparent to the user.
Additional Context
This change was inspired by the last few days of using Mlem. As a new Lemmy user who hasn't subscribed to many communities, I prefer to browse the All Posts feed. The default Hot sort is not very useful in this case, as the content is essentially unchanged for the last several days. Remembering my last selected
FeedType
andSortingOptions
lets me get right into the app and start browsing.I considered adding a sort preference in Settings (to match the Default Comment Sort option that already exists). However I hesitate to add two different UIs for a single preference; it seems to me that allowing the user to pick their preferred sort in context makes a lot of sense, and it's reasonable to expect that the app would remember this preference. Happy to adjust the implementation if an explicit setting is preferred.
Similar for FeedType -- it just makes sense that the app would remember which feed you browse.
A note on NSUserDefault keys: it may be useful to consider scoping the preferences a bit more specifically. For example in the future it may be best to persist sort options (for example) for each applicable screen; user feeds may have a different preferred sort than the post feed. Or taking it a step further, users may expect All Posts to sort differently than Subscribed or Local feeds. I suggest a reverse-domain approach.