Compare commits

..

2 Commits

Author SHA1 Message Date
Amit Salunke 3d7a285db3 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>
2026-10-20 04:36:02 +00:00
ShivaniKhaire 4ef5c1cab9 fix repeated click duplicate pages (#43) 2026-10-15 14:48:12 +05:30
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"; 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 * as RN from "react-native";
import { import {
useFonts, useFonts,