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