OmerFlame / SwiftRant

devRant API library made in Swift.
GNU General Public License v3.0
3 stars 1 forks source link

Added Sort and Range for the rant feed #21

Closed WilhelmOks closed 2 years ago

WilhelmOks commented 2 years ago

Added Sort and Range for the rant feed so that it can be configured like in the official devRant app.

I am a bit worried about the last set that is stored in UserDefaults (DRLastSet). That will probably not work well together with switching Sort for the feed. And I don't have a good idea how to handle it. Maybe remove the automatic storage by SwiftRant and leave it to handle for the user of SwiftRant? Because only the user knows when it is appropriate to clear the last set, e.g. when switching to another Sort mode, etc.

This should work fine with shouldUseKeychainAndUserDefaults==false, though.

OmerFlame commented 2 years ago

The last set stuff is only to unlock certain functionality of the API, that being the feature where you can get different feeds every request for pagination. It is not strictly required for the endpoint to operate, obviously. Also, if we think about how the set should work in essence, we can probably say that the set is based on continuity. that's why the endpoint is asking for the last set that was provided, in order to establish what was provided before and under what premises. If the premises don't conform to the ones sent to the server (i.e. algo/hot/latest), it should just ignore the set and send in a new feed, while disregarding the last set and providing a new one.

However, this is all just speculation.

We can just recommend to the developers that when switching modes, they should clear out the DRLastSet value before ever calling the fetch due to unknown behavior.