fix(native): first visits no longer wait behind the offline warm-up, day rail follows the swipe

The iOS app pulls every file of a build into WebKit's cache so it can start
offline. It did so four at a time at normal priority, for all 1,900 files of
every new build including all 27 translations, and a page opened meanwhile
queued behind it: right after a server update, a first visit to Vacay took
five to seven seconds. The warm-up now runs two at a time at low priority,
takes only the user's language and English, and walks a build once.

The day rail in the trip header lit the new day only after the pager's snap
had landed and the plan had re-rendered, a second or two after the swipe.
The pager now reports the day a swipe heads for as soon as its page is the
nearer one, and the rail and its pill move with the finger; the plan still
switches when the snap lands.
This commit is contained in:
Maurice
2026-11-06 15:37:55 +01:00
parent 431cc226e3
commit e3541535e2
12 changed files with 204 additions and 22 deletions
+24
View File
@@ -44,9 +44,33 @@ export function retryUrlFor(error: unknown): string | null {
return busted.href;
}
/** Every route loader, so the phone can fetch them ahead while idle (preloadLazyRoutes). */
const loaders: (() => Promise<unknown>)[] = [];
/**
* Fetches every lazily loaded page in the background, a few at a time, so
* opening one later does not wait for the network. A loader that fails is
* simply tried again when the page is opened. Skipped where the user asked to
* save data.
*/
export function preloadLazyRoutes(): void {
const connection = (navigator as { connection?: { saveData?: boolean } }).connection;
if (connection?.saveData) return;
const queue = [...loaders];
const next = () => {
const load = queue.shift();
if (!load) return;
void load()
.catch(() => {})
.then(next);
};
for (let i = 0; i < 3; i++) next();
}
export function lazyWithRetry<T extends ComponentType<any>>(
load: () => Promise<{ default: T }>
): LazyExoticComponent<T> {
loaders.push(load);
return lazy(() =>
load()
.catch((error: unknown) => {