Skip to content

armgit / TREK

Public Imported from GitHub
0

The most complete open-source travel planner: real-time collaboration, bookings, budgets, packing lists, journals, offline PWA, SSO and an AI-ready MCP server, with planet-wide place search and routing built in.

fix(ci): the Android merge passes the client gates

Maurice5ca44453ae9c
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<DOMRectReadOnly, 'left' | 'top' | 'right' | 'bottom'>;
}
/** 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<boolean> {
if (!canAddToGoogleWallet()) return false;
if (googleState === 'yes' || googleState === 'no') return googleState === 'yes';
@@ -94,18 +99,15 @@ export async function loadGoogleWalletAvailability(tripId: number): Promise<bool
// Offline: ask again next time.
setGoogleState('unknown');
}
- return googleState === 'yes';
+ return googleSaidYes();
}
/** True once this server has said Google Wallet works; asks it the first time a booking shows. */
export function useGoogleWalletAvailable(tripId: number): boolean {
- const available = useSyncExternalStore(
- (listener) => {
- 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]);