Mobile App: Week 11

by Shiva Gupta

week
gsoc
gsoc2026
mobile
react-native
week#11
Phase-2

Week Summary

Week 11 was the Tablet of the Day hero card on Home. The card itself is straightforward. Choosing which tablet is the harder half, because the requirement is one per day with no repeats until the whole catalogue has been used.

The obvious approach, and why I didn’t take it: store the ids you’ve already shown, pick randomly from what’s left. That needs storage, which brings three problems. Every device sees a different tablet, which undercuts the whole idea of a “Tablet of the Day”. Clearing app storage restarts the cycle and causes repeats. And it’s more moving parts to keep correct.

What I did instead - a date-seeded permutation, with no storage at all:

day      = local calendar date as an integer
cycle    = floor(day / 527)
position = day % 527
today    = shuffle(ids, seed = cycle)[position]

Walking a permutation in order gives the no-repeat guarantee for free - every one of the 527 tablets appears exactly once per cycle, and seeding the shuffle with the cycle number means the next pass through the catalogue gets a fresh order rather than replaying the same sequence. Being stateless, it’s the same tablet for every user on a given day, it works offline, and it survives a cleared cache.

Math.random can’t be seeded, so the shuffle needs its own generator - a small mulberry32 feeding a Fisher-Yates shuffle. Both are a few lines and fully deterministic. I derive the day number from the local calendar date rather than raw Date.now(), so the card turns over at local midnight instead of 05:30 IST.

There is one honest limitation, and it’s the price of statelessness: if a curator adds a tablet, the collection size changes, so both the permutation and the position shift and the day’s pick can change mid-day. It stays a valid tablet, just not the one shown an hour earlier. Caching the day’s choice in MMKV would fix it, at the cost of everything statelessness buys - so I’ve documented it rather than traded it away.

The card: full-bleed image, a “Daily Tablet” pill, the title, a two-line description and an Explore Detail button, with the whole card tapping through to the detail screen. Two things I got wrong first time and fixed:

The blurb needed a small helper too - some blurbs contain HTML (<a> <i> <sup> <sub>), so the preview strips tags before truncating to two lines. I checked the whole catalogue first: only those four tags, no entities, no empty blurbs, so a tiny strip is safe here rather than a guess.

Work Breakdown

Area What I did MR
Selection Date-seeded permutation (mulberry32 + Fisher-Yates), no repeats per cycle, no storage !11
Verification Confirmed 527 distinct picks across three full cycles, different order each cycle !11
Hero card 4:3 card matching the source images, full-card overlay, Explore Detail !11
Helper plainText for the blurb preview !11

What’s next