diff --git a/src/components/main/AppInactive.tsx b/src/components/main/AppInactive.tsx index 8ae585be7..c055417db 100644 --- a/src/components/main/AppInactive.tsx +++ b/src/components/main/AppInactive.tsx @@ -1,6 +1,8 @@ import type { FC } from '../../lib/teact/teact'; import React, { useCallback } from '../../lib/teact/teact'; +import useHistoryBack from '../../hooks/useHistoryBack'; + import Button from '../ui/Button'; import appInactivePath from '../../assets/app-inactive.png'; @@ -11,6 +13,12 @@ const AppInactive: FC = () => { window.location.reload(); }, []); + useHistoryBack({ + isActive: true, + onBack: handleReload, + shouldResetUrlHash: true, + }); + return (
diff --git a/src/hooks/useHistoryBack.ts b/src/hooks/useHistoryBack.ts index 4d0f79e38..833fba760 100644 --- a/src/hooks/useHistoryBack.ts +++ b/src/hooks/useHistoryBack.ts @@ -231,13 +231,14 @@ window.addEventListener('popstate', ({ state }: PopStateEvent) => { export default function useHistoryBack({ isActive, shouldBeReplaced, + shouldResetUrlHash, hash, onBack, }: { isActive?: boolean; shouldBeReplaced?: boolean; hash?: string; - title?: string; + shouldResetUrlHash?: boolean; onBack: VoidFunction; }) { // Active index of the record @@ -279,9 +280,10 @@ export default function useHistoryBack({ index: indexRef.current, historyUniqueSessionId, }, - hash: hash ? `#${hash}` : undefined, + // Space is a hack to make the browser completely remove the hash + hash: hash ? `#${hash}` : (shouldResetUrlHash ? ' ' : undefined), }); - }, [hash, onBack, shouldBeReplaced]); + }, [hash, onBack, shouldBeReplaced, shouldResetUrlHash]); const processBack = useCallback(() => { // Only process back on open records