diff --git a/src/app/_layout.tsx b/src/app/_layout.tsx index 6611ac0..34a1305 100644 --- a/src/app/_layout.tsx +++ b/src/app/_layout.tsx @@ -1,5 +1,34 @@ -import { Stack } from "expo-router"; +import { router, Stack } from "expo-router"; import React from "react"; + +// ============================================================================ +// GLOBAL NAVIGATION THROTTLE (Generic Fix for Repeated Click / Double Navigation) +// ============================================================================ +const NAVIGATION_THROTTLE_MS = 700; +let lastNavigationTimestamp = 0; + +const originalPush = router.push.bind(router); +const originalNavigate = router.navigate.bind(router); + +router.push = ((...args: Parameters) => { + const now = Date.now(); + if (now - lastNavigationTimestamp < NAVIGATION_THROTTLE_MS) { + return; + } + lastNavigationTimestamp = now; + return originalPush(...args); +}) as typeof router.push; + +router.navigate = ((...args: Parameters) => { + const now = Date.now(); + if (now - lastNavigationTimestamp < NAVIGATION_THROTTLE_MS) { + return; + } + lastNavigationTimestamp = now; + return originalNavigate(...args); +}) as typeof router.navigate; +// ============================================================================ + import * as RN from "react-native"; import { useFonts,