Use global navigation history stack

The readers history stack was different to the one from the rest of the app, resulting in an infinite loop when using the closing the reader and using the back button in the manga page, since the back button just opened the reader again.

Regression introduced with 4bb458778e
This commit is contained in:
schroda
2024-06-14 13:32:54 +02:00
parent 7266270075
commit 7337c18c7b
4 changed files with 26 additions and 9 deletions

View File

@@ -9,6 +9,7 @@
import React, { useCallback, useMemo, useState } from 'react';
import { INavbarOverride } from '@/typings';
import { NavBarContext } from '@/components/context/NavbarContext';
import { useHistory } from '@/util/useHistory.ts';
interface IProps {
children: React.ReactNode;
@@ -23,6 +24,8 @@ export function NavBarContextProvider({ children }: IProps) {
value: <div />,
});
const history = useHistory();
const updateTitle = useCallback(
(newTitle: string | React.ReactNode, browserTitle: string = typeof newTitle === 'string' ? newTitle : '') => {
document.title = `${browserTitle} - Suwayomi`;
@@ -33,6 +36,7 @@ export function NavBarContextProvider({ children }: IProps) {
const value = useMemo(
() => ({
history,
defaultBackTo,
setDefaultBackTo,
title,
@@ -42,7 +46,7 @@ export function NavBarContextProvider({ children }: IProps) {
override,
setOverride,
}),
[defaultBackTo, setDefaultBackTo, title, updateTitle, action, setAction, override, setOverride],
[history, defaultBackTo, setDefaultBackTo, title, updateTitle, action, setAction, override, setOverride],
);
return <NavBarContext.Provider value={value}>{children}</NavBarContext.Provider>;
}