fix(boot): native offline-first launch is silent and fast (Android 10)
Two native offline-first boot glitches (seen on Android 10): - bootOffline forced offlineNoNetwork, so its first successful reconcile healed to online with a spurious "back online" toast on a first launch that actually had connectivity. The boot-assumed offline is now PROVISIONAL: the first probe confirms it — a success heals silently (nothing to come back from), a failure turns it into a real offline whose later recovery does toast. - A native launch with a cached guest session (no email) skipped the offline short-circuit and hung ~25 s on adoptSession's retrying profile fetch in airplane mode. The native channel is offline-first, so it now takes the same reachability-gated fallback (~3 s bound) as an installed email PWA.
This commit is contained in:
@@ -248,3 +248,31 @@ describe('reduce — purity', () => {
|
||||
expect(prev).toEqual({ state: 'connecting', fails: 1, connectingSince: 5 });
|
||||
});
|
||||
});
|
||||
|
||||
// A boot-assumed (provisional) offline — bootOffline sets this — heals SILENTLY on its first
|
||||
// successful probe (a first launch that actually had connectivity must not flash "back online"),
|
||||
// while a failed probe confirms it as a real offline whose later recovery does toast.
|
||||
describe('provisional (boot-assumed) offline', () => {
|
||||
const bootOffline: NetSnapshot = { state: 'offlineNoNetwork', fails: 0, connectingSince: 0, provisional: true };
|
||||
|
||||
it('heals to online with NO toast when the first probe succeeds', () => {
|
||||
const r = reduce(bootOffline, e('probeOk'), cfg);
|
||||
expect(r.next.state).toBe('online');
|
||||
expect(r.effects).toEqual([]); // no "back online" toast — it was never really offline
|
||||
});
|
||||
|
||||
it('clears provisional on a failed probe, then toasts on the eventual recovery', () => {
|
||||
const failed = reduce(bootOffline, e('probeFailed'), cfg);
|
||||
expect(failed.next.state).toBe('offlineNoNetwork');
|
||||
expect(failed.next.provisional).toBe(false);
|
||||
expect(failed.effects).toEqual([]);
|
||||
const healed = reduce(failed.next, e('probeOk'), cfg);
|
||||
expect(healed.next.state).toBe('online');
|
||||
expect(healed.effects).toEqual([{ kind: 'toast', toast: 'online' }]); // now a real recovery
|
||||
});
|
||||
|
||||
it('a non-provisional (observed) offline still toasts on recovery', () => {
|
||||
const r = reduce(offline, e('probeOk'), cfg);
|
||||
expect(r.effects).toEqual([{ kind: 'toast', toast: 'online' }]);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user