You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
33 lines
967 B
33 lines
967 B
"use client";
|
|
|
|
import { useEffect } from "react";
|
|
import {
|
|
handleHardwareBack,
|
|
handleHardwareBackSync,
|
|
} from "@/hooks/use-hardware-back-handler";
|
|
|
|
/**
|
|
* Wires the React hardware-back handler stack to the global
|
|
* window.__habibHandleHardwareBack and window.__habibHandleHardwareBackSync functions.
|
|
*
|
|
* Mount this once in the Providers tree (after React hydration).
|
|
* It replaces the bootstrap stub with the real handler that walks
|
|
* the registered stack.
|
|
*/
|
|
export function HardwareBackBridge() {
|
|
useEffect(() => {
|
|
window.__habibHandleHardwareBack = handleHardwareBack;
|
|
window.__habibHandleHardwareBackSync = handleHardwareBackSync;
|
|
|
|
return () => {
|
|
// On unmount (shouldn't happen in practice), restore the stubs.
|
|
window.__habibHandleHardwareBack = () =>
|
|
Promise.resolve({ handled: false });
|
|
window.__habibHandleHardwareBackSync = () => false;
|
|
};
|
|
}, []);
|
|
|
|
return null;
|
|
}
|
|
|
|
export default HardwareBackBridge;
|