diff --git a/src/components/context/NavbarContext.tsx b/src/components/context/NavbarContext.tsx index de65ebf6..6d83cf09 100644 --- a/src/components/context/NavbarContext.tsx +++ b/src/components/context/NavbarContext.tsx @@ -6,16 +6,12 @@ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ -import React, { useContext, useEffect } from 'react'; +import React, { useContext } from 'react'; import { INavbarOverride } from '@/typings'; type ContextType = { history: string[]; - // Default back button url - defaultBackTo: string | undefined; - setDefaultBackTo: React.Dispatch>; - // AppBar title title: string | React.ReactNode; setTitle: (title: ContextType['title'], browserTitle?: string) => void; @@ -31,8 +27,6 @@ type ContextType = { export const NavBarContext = React.createContext({ history: [], - defaultBackTo: undefined, - setDefaultBackTo: (): void => {}, title: 'Suwayomi', setTitle: (): void => {}, action:
, @@ -42,12 +36,3 @@ export const NavBarContext = React.createContext({ }); export const useNavBarContext = () => useContext(NavBarContext); - -export const useSetDefaultBackTo = (value: string) => { - const { setDefaultBackTo } = useNavBarContext(); - - useEffect(() => { - setDefaultBackTo(value); - return () => setDefaultBackTo(undefined); - }, [value]); -}; diff --git a/src/components/navbar/NavBarContextProvider.tsx b/src/components/navbar/NavBarContextProvider.tsx index 650ce310..a07b2ac6 100644 --- a/src/components/navbar/NavBarContextProvider.tsx +++ b/src/components/navbar/NavBarContextProvider.tsx @@ -16,7 +16,6 @@ interface IProps { } export function NavBarContextProvider({ children }: IProps) { - const [defaultBackTo, setDefaultBackTo] = useState(); const [title, setTitle] = useState('Suwayomi'); const [action, setAction] = useState(
); const [override, setOverride] = useState({ @@ -37,8 +36,6 @@ export function NavBarContextProvider({ children }: IProps) { const value = useMemo( () => ({ history, - defaultBackTo, - setDefaultBackTo, title, setTitle: updateTitle, action, @@ -46,7 +43,7 @@ export function NavBarContextProvider({ children }: IProps) { override, setOverride, }), - [history, defaultBackTo, setDefaultBackTo, title, updateTitle, action, setAction, override, setOverride], + [history, title, updateTitle, action, setAction, override, setOverride], ); return {children}; } diff --git a/src/components/navbar/ReaderNavBar.tsx b/src/components/navbar/ReaderNavBar.tsx index bd84c5c5..46a5a6b3 100644 --- a/src/components/navbar/ReaderNavBar.tsx +++ b/src/components/navbar/ReaderNavBar.tsx @@ -30,7 +30,6 @@ import { useTranslation } from 'react-i18next'; import { AllowedMetadataValueTypes, ChapterOffset, IReaderSettings, TChapter, TManga } from '@/typings'; import { ReaderSettingsOptions } from '@/components/reader/ReaderSettingsOptions'; import { useBackButton } from '@/util/useBackButton.ts'; -import { useSetDefaultBackTo } from '@/components/context/NavbarContext.tsx'; import { Select } from '@/components/atoms/Select.tsx'; import { getOptionForDirection } from '@/theme.ts'; @@ -155,7 +154,6 @@ export function ReaderNavBar(props: IProps) { } = props; const handleBack = useBackButton(); - useSetDefaultBackTo(`/manga/${manga.id}`); const hasMultipleScanlators = useMemo(() => !!new Set(chapters.map(({ scanlator }) => scanlator)).size, [chapters]); diff --git a/src/util/useBackButton.ts b/src/util/useBackButton.ts index 4641d179..c0ca59b1 100644 --- a/src/util/useBackButton.ts +++ b/src/util/useBackButton.ts @@ -13,7 +13,7 @@ import { NavBarContext } from '@/components/context/NavbarContext.tsx'; export const useBackButton = () => { const navigate = useNavigate(); const location = useLocation(); - const { history, defaultBackTo: backToUrl } = useContext(NavBarContext); + const { history } = useContext(NavBarContext); return () => { const isHistoryEmpty = !history.length; @@ -25,11 +25,6 @@ export const useBackButton = () => { return; } - if (backToUrl) { - navigate(backToUrl); - return; - } - navigate('/library'); }; };