Files
suwayomi-material-you-webui/src/components/context/NavbarContext.tsx
schroda 36e943214c Remove "default back to" functionality
Caused an infinite loop, because in case the Reader was the initial opened page, got closed and the back button was pressed, the Reader just got opened again.

This happened because in case it was the initial opened page, closing the Reader did not use the browser back navigation and instead opened the Manga page, resulting in it to be pushed in the history stack with the Reader being the previous page
2024-06-14 15:17:05 +02:00

39 lines
1.1 KiB
TypeScript

/*
* Copyright (C) Contributors to the Suwayomi project
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*/
import React, { useContext } from 'react';
import { INavbarOverride } from '@/typings';
type ContextType = {
history: string[];
// AppBar title
title: string | React.ReactNode;
setTitle: (title: ContextType['title'], browserTitle?: string) => void;
// AppBar action buttons
action: any;
setAction: React.Dispatch<React.SetStateAction<any>>;
// Allow default navbar to be overrided
override: INavbarOverride;
setOverride: React.Dispatch<React.SetStateAction<INavbarOverride>>;
};
export const NavBarContext = React.createContext<ContextType>({
history: [],
title: 'Suwayomi',
setTitle: (): void => {},
action: <div />,
setAction: (): void => {},
override: { status: false, value: <div /> },
setOverride: (): void => {},
});
export const useNavBarContext = () => useContext(NavBarContext);