fix(invite): normalize canAddPasses() return for simulator runtimes

The native module's TS signature is Promise<boolean>, but the iOS
simulator can return undefined synchronously since PassKit isn't fully
wired there. Wrap in Promise.resolve so both shapes flow through the
same .then/.catch path.
This commit is contained in:
vineyardbovines
2026-06-26 12:01:46 -04:00
parent 54deb3ca0f
commit 3f71ebd779
@@ -23,9 +23,12 @@ export function AddToWalletButton({handle}: {handle: string}) {
// Skip the native check if the handle is already known to be unusable. // Skip the native check if the handle is already known to be unusable.
if (!handle || handle === 'handle.invalid') return if (!handle || handle === 'handle.invalid') return
let cancelled = false let cancelled = false
;(RNWallet.canAddPasses() as Promise<boolean>) // The native module's TS signature is Promise<boolean>, but on the iOS
.then((ok: boolean) => { // simulator PassKit isn't fully wired and canAddPasses() can return
if (!cancelled) setCanAdd(ok) // undefined synchronously - Promise.resolve normalizes both shapes.
Promise.resolve(RNWallet.canAddPasses() as Promise<boolean> | undefined)
.then(ok => {
if (!cancelled) setCanAdd(ok === true)
}) })
.catch(() => { .catch(() => {
if (!cancelled) setCanAdd(false) if (!cancelled) setCanAdd(false)