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:
@@ -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)
|
||||||
|
|||||||
Reference in New Issue
Block a user