Remove most "useSetDefaultBackTo" usage
In case the "depth" of the initial opened app page was greater than 2 it was possible to get stuck in a loop of using the back button twice from the initial page to the previous page and back to the initial page... Instead, in case a page with a greater depth than 0 is opened, the library should just be opened when using the back button. This way the back button actually behaves like it's intended, as an app back button and not like the browsers back button
This commit is contained in:
@@ -16,7 +16,7 @@ import { updateMetadataServerSettings, useMetadataServerSettings } from '@/lib/m
|
||||
import { MetadataServerSettingKeys, MetadataServerSettings } from '@/typings.ts';
|
||||
import { makeToast } from '@/components/util/Toast.tsx';
|
||||
import { MutableListSetting } from '@/components/settings/MutableListSetting.tsx';
|
||||
import { NavBarContext, useSetDefaultBackTo } from '@/components/context/NavbarContext.tsx';
|
||||
import { NavBarContext } from '@/components/context/NavbarContext.tsx';
|
||||
import { ActiveDevice, DEFAULT_DEVICE } from '@/util/device.ts';
|
||||
import { Select } from '@/components/atoms/Select.tsx';
|
||||
import { LoadingPlaceholder } from '@/components/util/LoadingPlaceholder.tsx';
|
||||
@@ -27,8 +27,6 @@ export const DeviceSetting = () => {
|
||||
const { t } = useTranslation();
|
||||
const { setTitle, setAction } = useContext(NavBarContext);
|
||||
|
||||
useSetDefaultBackTo('settings');
|
||||
|
||||
useEffect(() => {
|
||||
setTitle(t('settings.device.title.settings'));
|
||||
setAction(null);
|
||||
|
||||
@@ -17,7 +17,7 @@ import { useTranslation } from 'react-i18next';
|
||||
import { useParams } from 'react-router-dom';
|
||||
import { isNetworkRequestInFlight } from '@apollo/client/core/networkStatus';
|
||||
import { requestManager } from '@/lib/requests/RequestManager.ts';
|
||||
import { NavBarContext, useSetDefaultBackTo } from '@/components/context/NavbarContext';
|
||||
import { NavBarContext } from '@/components/context/NavbarContext';
|
||||
import { ChapterList } from '@/components/chapter/ChapterList.tsx';
|
||||
import { useRefreshManga } from '@/components/manga/useRefreshManga.ts';
|
||||
import { MangaDetails } from '@/components/manga/MangaDetails';
|
||||
@@ -37,7 +37,6 @@ export const Manga: React.FC = () => {
|
||||
const manga = data?.manga;
|
||||
|
||||
const [refresh, { loading: refreshing, error: refreshError }] = useRefreshManga(id);
|
||||
useSetDefaultBackTo('library');
|
||||
|
||||
const error = mangaError ?? refreshError;
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ import { AppbarSearch } from '@/components/util/AppbarSearch';
|
||||
import { LangSelect } from '@/components/navbar/action/LangSelect';
|
||||
import { MangaGrid } from '@/components/MangaGrid';
|
||||
import { useDebounce } from '@/util/useDebounce.ts';
|
||||
import { NavBarContext, useSetDefaultBackTo } from '@/components/context/NavbarContext.tsx';
|
||||
import { NavBarContext } from '@/components/context/NavbarContext.tsx';
|
||||
import { MangaCardProps } from '@/components/manga/MangaCard.types.tsx';
|
||||
import { EmptyView } from '@/components/util/EmptyView';
|
||||
import { defaultPromiseErrorHandler } from '@/util/defaultPromiseErrorHandler.ts';
|
||||
@@ -187,8 +187,6 @@ export const SearchAll: React.FC = () => {
|
||||
|
||||
const { setTitle, setAction } = useContext(NavBarContext);
|
||||
|
||||
useSetDefaultBackTo('browse');
|
||||
|
||||
const { pathname, state } = useLocation<{ mangaTitle?: string }>();
|
||||
const isMigrateMode = pathname.startsWith('/migrate/source');
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@ import {
|
||||
GetSourceMangasFetchMutation,
|
||||
GetSourceMangasFetchMutationVariables,
|
||||
} from '@/lib/graphql/generated/graphql.ts';
|
||||
import { NavBarContext, useSetDefaultBackTo } from '@/components/context/NavbarContext.tsx';
|
||||
import { NavBarContext } from '@/components/context/NavbarContext.tsx';
|
||||
import { useMetadataServerSettings } from '@/lib/metadata/metadataServerSettings.ts';
|
||||
import { useSessionStorage } from '@/util/useStorage.tsx';
|
||||
import { AppStorage } from '@/util/AppStorage.ts';
|
||||
@@ -221,8 +221,6 @@ export function SourceMangas() {
|
||||
clearCache: boolean;
|
||||
}>().state ?? {};
|
||||
|
||||
useSetDefaultBackTo('browse');
|
||||
|
||||
const [isFirstRender, setIsFirstRender] = useState(true);
|
||||
|
||||
useEffect(() => {
|
||||
|
||||
@@ -24,7 +24,7 @@ import { t as translate } from 'i18next';
|
||||
import DownloadingIcon from '@mui/icons-material/Downloading';
|
||||
import { requestManager } from '@/lib/requests/RequestManager.ts';
|
||||
import { ListItemLink } from '@/components/util/ListItemLink';
|
||||
import { NavBarContext, useSetDefaultBackTo } from '@/components/context/NavbarContext';
|
||||
import { NavBarContext } from '@/components/context/NavbarContext';
|
||||
import { LoadingPlaceholder } from '@/components/util/LoadingPlaceholder';
|
||||
import { GetAboutQuery, UpdateState } from '@/lib/graphql/generated/graphql.ts';
|
||||
import { defaultPromiseErrorHandler } from '@/util/defaultPromiseErrorHandler.ts';
|
||||
@@ -201,8 +201,6 @@ export function About() {
|
||||
};
|
||||
}, [t]);
|
||||
|
||||
useSetDefaultBackTo('settings');
|
||||
|
||||
const { data, loading, error, refetch } = requestManager.useGetAbout({ notifyOnNetworkStatusChange: true });
|
||||
|
||||
const {
|
||||
|
||||
@@ -25,7 +25,7 @@ import { Link } from 'react-router-dom';
|
||||
import Stack from '@mui/material/Stack';
|
||||
import { requestManager } from '@/lib/requests/RequestManager.ts';
|
||||
import { makeToast } from '@/components/util/Toast';
|
||||
import { NavBarContext, useSetDefaultBackTo } from '@/components/context/NavbarContext';
|
||||
import { NavBarContext } from '@/components/context/NavbarContext';
|
||||
import { BackupRestoreState, ValidateBackupQuery } from '@/lib/graphql/generated/graphql.ts';
|
||||
import { Progress } from '@/components/util/Progress.tsx';
|
||||
import { TextSetting } from '@/components/settings/text/TextSetting.tsx';
|
||||
@@ -68,8 +68,6 @@ export function Backup() {
|
||||
};
|
||||
}, [t]);
|
||||
|
||||
useSetDefaultBackTo('settings');
|
||||
|
||||
const {
|
||||
data: settingsData,
|
||||
loading,
|
||||
|
||||
@@ -12,7 +12,7 @@ import List from '@mui/material/List';
|
||||
import ListItem from '@mui/material/ListItem';
|
||||
import ListItemText from '@mui/material/ListItemText';
|
||||
import Switch from '@mui/material/Switch';
|
||||
import { NavBarContext, useSetDefaultBackTo } from '@/components/context/NavbarContext.tsx';
|
||||
import { NavBarContext } from '@/components/context/NavbarContext.tsx';
|
||||
import { requestManager } from '@/lib/requests/RequestManager.ts';
|
||||
import { NumberSetting } from '@/components/settings/NumberSetting.tsx';
|
||||
import { MutableListSetting } from '@/components/settings/MutableListSetting.tsx';
|
||||
@@ -39,8 +39,6 @@ export const BrowseSettings = () => {
|
||||
const { t } = useTranslation();
|
||||
const { setTitle, setAction } = useContext(NavBarContext);
|
||||
|
||||
useSetDefaultBackTo('settings');
|
||||
|
||||
useEffect(() => {
|
||||
setTitle(t('settings.browse.title'));
|
||||
setAction(null);
|
||||
|
||||
@@ -32,7 +32,7 @@ import { useTranslation } from 'react-i18next';
|
||||
import { requestManager } from '@/lib/requests/RequestManager.ts';
|
||||
import { StrictModeDroppable } from '@/lib/StrictModeDroppable';
|
||||
import { DEFAULT_FULL_FAB_HEIGHT } from '@/components/util/StyledFab';
|
||||
import { NavBarContext, useSetDefaultBackTo } from '@/components/context/NavbarContext';
|
||||
import { NavBarContext } from '@/components/context/NavbarContext';
|
||||
import { TCategory } from '@/typings.ts';
|
||||
import { LoadingPlaceholder } from '@/components/util/LoadingPlaceholder.tsx';
|
||||
import { EmptyViewAbsoluteCentered } from '@/components/util/EmptyViewAbsoluteCentered.tsx';
|
||||
@@ -81,8 +81,6 @@ export function Categories() {
|
||||
const [reorderCategory, { reset: revertReorder }] = requestManager.useReorderCategory();
|
||||
const theme = useTheme();
|
||||
|
||||
useSetDefaultBackTo('settings');
|
||||
|
||||
const categoryReorder = (list: TCategory[], from: number, to: number) => {
|
||||
const reorderedCategory = list[from];
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ import {
|
||||
} from '@/lib/metadata/readerSettings.ts';
|
||||
import { ReaderSettingsOptions } from '@/components/reader/ReaderSettingsOptions';
|
||||
import { makeToast } from '@/components/util/Toast';
|
||||
import { NavBarContext, useSetDefaultBackTo } from '@/components/context/NavbarContext';
|
||||
import { NavBarContext } from '@/components/context/NavbarContext';
|
||||
import { defaultPromiseErrorHandler } from '@/util/defaultPromiseErrorHandler.ts';
|
||||
import { EmptyViewAbsoluteCentered } from '@/components/util/EmptyViewAbsoluteCentered.tsx';
|
||||
import { LoadingPlaceholder } from '@/components/util/LoadingPlaceholder.tsx';
|
||||
@@ -42,8 +42,6 @@ export function DefaultReaderSettings() {
|
||||
request: { error, refetch },
|
||||
} = useDefaultReaderSettings();
|
||||
|
||||
useSetDefaultBackTo('settings');
|
||||
|
||||
const setSettingValue = (key: keyof IReaderSettings, value: AllowedMetadataValueTypes, persist: boolean = true) => {
|
||||
if (persist) {
|
||||
requestUpdateServerMetadata([[key, value]]).catch(() =>
|
||||
|
||||
@@ -14,7 +14,7 @@ import ListItemText from '@mui/material/ListItemText';
|
||||
import Switch from '@mui/material/Switch';
|
||||
import ListSubheader from '@mui/material/ListSubheader';
|
||||
import { TextSetting } from '@/components/settings/text/TextSetting.tsx';
|
||||
import { NavBarContext, useSetDefaultBackTo } from '@/components/context/NavbarContext.tsx';
|
||||
import { NavBarContext } from '@/components/context/NavbarContext.tsx';
|
||||
import { MetadataDownloadSettings, ServerSettings } from '@/typings.ts';
|
||||
import { requestManager } from '@/lib/requests/RequestManager.ts';
|
||||
import { DownloadAheadSetting } from '@/components/settings/downloads/DownloadAheadSetting.tsx';
|
||||
@@ -53,8 +53,6 @@ export const DownloadSettings = () => {
|
||||
const { t } = useTranslation();
|
||||
const { setTitle, setAction } = useContext(NavBarContext);
|
||||
|
||||
useSetDefaultBackTo('settings');
|
||||
|
||||
useEffect(() => {
|
||||
setTitle(t('download.settings.title'));
|
||||
setAction(null);
|
||||
|
||||
@@ -15,7 +15,7 @@ import ListItemText from '@mui/material/ListItemText';
|
||||
import Switch from '@mui/material/Switch';
|
||||
import ListSubheader from '@mui/material/ListSubheader';
|
||||
import { t as translate } from 'i18next';
|
||||
import { NavBarContext, useSetDefaultBackTo } from '@/components/context/NavbarContext.tsx';
|
||||
import { NavBarContext } from '@/components/context/NavbarContext.tsx';
|
||||
import { GlobalUpdateSettings } from '@/components/settings/globalUpdate/GlobalUpdateSettings.tsx';
|
||||
import { MetadataLibrarySettings } from '@/typings.ts';
|
||||
import { makeToast } from '@/components/util/Toast.tsx';
|
||||
@@ -63,8 +63,6 @@ export function LibrarySettings() {
|
||||
};
|
||||
}, [t]);
|
||||
|
||||
useSetDefaultBackTo('settings');
|
||||
|
||||
const categories = requestManager.useGetCategories();
|
||||
const serverSettings = requestManager.useGetServerSettings({ notifyOnNetworkStatusChange: true });
|
||||
const {
|
||||
|
||||
@@ -14,7 +14,7 @@ import ListItem from '@mui/material/ListItem';
|
||||
import ListItemText from '@mui/material/ListItemText';
|
||||
import Switch from '@mui/material/Switch';
|
||||
import ListSubheader from '@mui/material/ListSubheader';
|
||||
import { NavBarContext, useSetDefaultBackTo } from '@/components/context/NavbarContext.tsx';
|
||||
import { NavBarContext } from '@/components/context/NavbarContext.tsx';
|
||||
import { requestManager } from '@/lib/requests/RequestManager.ts';
|
||||
import { useLocalStorage } from '@/util/useStorage.tsx';
|
||||
import { TextSetting } from '@/components/settings/text/TextSetting.tsx';
|
||||
@@ -79,8 +79,6 @@ export const ServerSettings = () => {
|
||||
const { t } = useTranslation();
|
||||
const { setTitle, setAction } = useContext(NavBarContext);
|
||||
|
||||
useSetDefaultBackTo('settings');
|
||||
|
||||
useEffect(() => {
|
||||
setTitle(t('settings.server.title.settings'));
|
||||
setAction(null);
|
||||
|
||||
@@ -12,7 +12,7 @@ import List from '@mui/material/List';
|
||||
import ListItem from '@mui/material/ListItem';
|
||||
import ListItemText from '@mui/material/ListItemText';
|
||||
import Switch from '@mui/material/Switch';
|
||||
import { NavBarContext, useSetDefaultBackTo } from '@/components/context/NavbarContext.tsx';
|
||||
import { NavBarContext } from '@/components/context/NavbarContext.tsx';
|
||||
import { MetadataUpdateSettings, ServerSettings } from '@/typings.ts';
|
||||
import { requestManager } from '@/lib/requests/RequestManager.ts';
|
||||
import { WebUIUpdateIntervalSetting } from '@/components/settings/webUI/WebUIUpdateIntervalSetting.tsx';
|
||||
@@ -120,8 +120,6 @@ export const WebUISettings = () => {
|
||||
const { t } = useTranslation();
|
||||
const { setTitle, setAction } = useContext(NavBarContext);
|
||||
|
||||
useSetDefaultBackTo('settings');
|
||||
|
||||
useEffect(() => {
|
||||
setTitle(t('settings.webui.title.settings'));
|
||||
setAction(null);
|
||||
|
||||
Reference in New Issue
Block a user