/** * Android hardware back button in the native app. * * Without a listener, Android closes the app on back — waiters would drop out of * the POS mid-service. Same intent as AndroidBackGuard for the installed PWA: * back never leaves the POS from a root screen. * * Decided by path, not by a history sentinel: Chrome's history intervention marks * entries pushed without a user gesture as skippable, so the WebView reports * canGoBack=false even with the sentinel in place. */ const ROOT_PATHS = ['/', '/tables', '/login'] export async function installBackButtonHandler() { const { App } = await import('@capacitor/app') App.addListener('backButton', ({ canGoBack }) => { if (ROOT_PATHS.includes(window.location.pathname)) return if (canGoBack) { window.history.back() } else { window.location.replace('/') } }) }