Merge pull request 'fix repeated click duplicate pages (#43)' (#67) from issue-43 into main

Reviewed-on: https://10.10.0.4/AcuPedia/acupedia-mobile-ui/pulls/67
Reviewed-by: Amit Salunke <amit@noreply.localhost>
This commit is contained in:
Amit Salunke 2026-10-20 04:36:02 +00:00
commit 3d7a285db3
1 changed files with 30 additions and 1 deletions

View File

@ -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<typeof originalPush>) => {
const now = Date.now();
if (now - lastNavigationTimestamp < NAVIGATION_THROTTLE_MS) {
return;
}
lastNavigationTimestamp = now;
return originalPush(...args);
}) as typeof router.push;
router.navigate = ((...args: Parameters<typeof originalNavigate>) => {
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,