Extract app page history from nav bar context

This commit is contained in:
schroda
2025-01-21 20:26:03 +01:00
parent 9b883a5170
commit 480eaf5a08
7 changed files with 50 additions and 25 deletions

View File

@@ -8,15 +8,15 @@
import { useLocation, useNavigate } from 'react-router-dom';
import { useCallback } from 'react';
import { useNavBarContext } from '@/modules/navigation-bar/contexts/NavbarContext.tsx';
import { AppRoutes } from '@/modules/core/AppRoute.constants.ts';
import { useAppPageHistoryContext } from '@/modules/core/contexts/AppPageHistoryContext.tsx';
const PAGES_TO_IGNORE: readonly RegExp[] = [/\/manga\/[0-9]+\/chapter\/[0-9]+/g];
export const useBackButton = () => {
const navigate = useNavigate();
const location = useLocation();
const { history } = useNavBarContext();
const history = useAppPageHistoryContext();
return useCallback(() => {
const isHistoryEmpty = !history.length;