From 5ca44453ae9cb880ccd908b93598d650104957e5 Mon Sep 17 00:00:00 2001 From: Maurice Date: Sat, 7 Nov 2026 17:13:47 +0100 Subject: [PATCH] fix(ci): the Android merge passes the client gates - wallet.ts: the Google Wallet state is read through a function after it was set, so TypeScript no longer narrows it to its old value (TS2367) - iap.ts: a store listener that cannot be added is reported through reportNativeFailure instead of an empty catch - iap.test.ts: the restored purchase is checked instead of asserted non-null - trekShell.ts: the fold's rectangle is typed as a DOMRect pick, geometry the RTL lint does not read as text sides --- client/src/native/iap.test.ts | 3 ++- client/src/native/iap.ts | 6 +++++- client/src/native/trekShell.ts | 3 ++- client/src/native/wallet.ts | 18 ++++++++++-------- 4 files changed, 19 insertions(+), 11 deletions(-) diff --git a/client/src/native/iap.test.ts b/client/src/native/iap.test.ts index 0bf8e2ea5..4b78d5494 100644 --- a/client/src/native/iap.test.ts +++ b/client/src/native/iap.test.ts @@ -174,7 +174,8 @@ describe('native client on Android (Google Play Billing)', () => { shell.storeRestore.mockResolvedValue({}); expect(await nativeIapClient.restore()).toBeNull(); shell.storeFinish.mockResolvedValue(undefined); - await nativeIapClient.finish(purchase!); + if (!purchase) throw new Error('expected the restored purchase'); + await nativeIapClient.finish(purchase); expect(shell.storeFinish).toHaveBeenCalledWith({ transactionId: 'token-2' }); }); diff --git a/client/src/native/iap.ts b/client/src/native/iap.ts index b1a655cda..e28c3a5f8 100644 --- a/client/src/native/iap.ts +++ b/client/src/native/iap.ts @@ -1,4 +1,5 @@ import { isNativeAndroid, isNativeIos } from './platform'; +import { reportNativeFailure } from './reportFailure'; import { TrekShell, type StoreRestoreResult } from './trekShell'; /** @@ -185,7 +186,10 @@ export const nativeIapClient: IapClient = { }, onTransaction(listener) { if (nativeStore()?.platform !== 'google') return; - void TrekShell.addListener('storeTransaction', () => listener()).catch(() => {}); + void TrekShell.addListener('storeTransaction', () => listener()).catch((err: unknown) => { + // Without the listener a renewal that clears later is still picked up by the next restore; nothing to undo. + reportNativeFailure(err); + }); }, async restore() { try { diff --git a/client/src/native/trekShell.ts b/client/src/native/trekShell.ts index aebf46b6d..2a7826a91 100644 --- a/client/src/native/trekShell.ts +++ b/client/src/native/trekShell.ts @@ -151,7 +151,8 @@ interface NativeWindowLayout { orientation?: 'vertical' | 'horizontal'; separating?: boolean; occluding?: boolean; - hinge?: { left: number; top: number; right: number; bottom: number }; + /** The fold's rectangle on the screen, in CSS pixels: geometry, not text sides. */ + hinge?: Pick; } /** A position, or an error shaped like GeolocationPositionError (1 denied, 2 unavailable). */ diff --git a/client/src/native/wallet.ts b/client/src/native/wallet.ts index 07c9916b4..c58779931 100644 --- a/client/src/native/wallet.ts +++ b/client/src/native/wallet.ts @@ -81,6 +81,11 @@ function setGoogleState(next: typeof googleState): void { for (const listener of googleListeners) listener(); } +/** Read through a call, so a check after setGoogleState() sees the new state rather than a narrowed one. */ +function googleSaidYes(): boolean { + return googleState === 'yes'; +} + export async function loadGoogleWalletAvailability(tripId: number): Promise { if (!canAddToGoogleWallet()) return false; if (googleState === 'yes' || googleState === 'no') return googleState === 'yes'; @@ -94,18 +99,15 @@ export async function loadGoogleWalletAvailability(tripId: number): Promise { - googleListeners.add(listener); - return () => googleListeners.delete(listener); - }, - () => googleState === 'yes' - ); + const available = useSyncExternalStore((listener) => { + googleListeners.add(listener); + return () => googleListeners.delete(listener); + }, googleSaidYes); useEffect(() => { void loadGoogleWalletAvailability(tripId); }, [tripId]);