mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-19 21:06:09 +00:00
itch.io: browse the Store tab by sort and price, with paging and a disk cache
The Store tab only had four fixed shelves and a title search. A row of sort (Popular, New, Top rated, Top sellers) and price (Any, Free, On sale) chips now sets a BrowseQuery; anything but the defaults swaps the shelves for that query's games, loaded page by page as the grid scrolls. ItchBrowse builds itch's listing-feed URL (platform and tag segments are in the builder for the next change), tries each spelling of a price filter until one answers, spaces requests 1.2 s apart, backs off once on a 429, and keeps pages in the app cache for three hours. Every request is logged with its status and game count so a wrong URL guess can be fixed from a device. Owned games replace their browse copy so Install and the owned markers are right, and the detail page finds browse results. Strings for all 33 locales; URL-builder tests; docs/development/itch-browse.md.
This commit is contained in:
40 files changed
+708
-8
No files matched your search
@@ -0,0 +1,30 @@
|
||||
# itch.io browsing
|
||||
|
||||
The itch Store tab opens on the front page shelves. A row of chips above them (`ui/ItchBrowseBar.kt`)
|
||||
sets an order (Popular, New, Top rated, Top sellers) and a price (Any, Free, On sale). Leave both at
|
||||
their defaults and the shelves stay; pick anything else and the tab shows that query's games as a grid
|
||||
that loads the next page as it scrolls into view.
|
||||
|
||||
## Data
|
||||
|
||||
`ItchBrowse` (`stores/itch/ItchBrowse.kt`) turns a `BrowseQuery` into itch's listing feed:
|
||||
|
||||
```
|
||||
https://itch.io/games[/<sort>][/<price>][/platform-<name>...][/tag-<slug>...].xml[?page=N]
|
||||
```
|
||||
|
||||
`BrowseQuery` already carries platforms and tags, so the URL builder is complete; the controls for them
|
||||
come in a later change. A price filter has more than one spelling on itch, so `urls()` returns every
|
||||
candidate and `page()` takes the first that answers with games. Every request is logged
|
||||
(`itch.io browse: <url> answered <code> with <n> games`), which is how a wrong guess is found and fixed
|
||||
from a device.
|
||||
|
||||
Requests go out one at a time, at least 1.2 s apart. A 429 waits 8 s and tries once more; if that fails
|
||||
the games already on screen stay. Each page is kept under the app cache for three hours, so going back to
|
||||
a query does not ask itch again. Results are parsed by `ItchShelves.parse`, the same reader the shelves
|
||||
use, so a game looks the same wherever it appears.
|
||||
|
||||
`ItchBrowseState` holds the query, the games loaded so far and whether more can be asked for. A newer
|
||||
query bumps a generation counter, so a slow answer for an older one is dropped. A game already in the
|
||||
library replaces its browse copy on the grid, so Install and the owned markers are right; the detail page
|
||||
looks browse results up through `StoresState.detailItem`.
|
||||
Reference in new issue
Block a user