From cff0ed5ec3f77a5961fbff2975522680e9afd6e9 Mon Sep 17 00:00:00 2001
From: schroda <50052685+schroda@users.noreply.github.com>
Date: Wed, 11 Dec 2024 20:10:59 +0100
Subject: [PATCH] Extract app routes into constant
---
src/App.tsx | 70 ++++----
.../components/ServerUpdateChecker.tsx | 3 +-
src/modules/backup/screens/Backup.tsx | 5 +-
.../category/components/CategorySelect.tsx | 3 +-
src/modules/chapter/services/Chapters.ts | 3 +-
src/modules/core/AppRoute.constants.ts | 157 ++++++++++++++++++
src/modules/core/hooks/useBackButton.ts | 3 +-
.../downloads/screens/DownloadQueue.tsx | 3 +-
src/modules/extension/screens/Extensions.tsx | 3 +-
.../global-search/screens/SearchAll.tsx | 7 +-
.../library/screens/LibrarySettings.tsx | 3 +-
.../components/ContinueReadingButton.tsx | 3 +-
.../manga/components/MangaActionMenuItems.tsx | 3 +-
.../manga/components/MangaToolbarMenu.tsx | 5 +-
.../manga/components/TrackMangaButton.tsx | 4 +-
.../manga/components/cards/MangaCard.tsx | 5 +-
.../hooks/useManageMangaLibraryState.tsx | 3 +-
.../migration/components/MigrateDialog.tsx | 9 +-
.../migration/components/MigrationCard.tsx | 3 +-
.../components/DefaultNavBar.tsx | 11 +-
.../overlay/ReaderOverlayHeaderMobile.tsx | 3 +-
.../desktop/ReaderNavBarDesktopMetadata.tsx | 7 +-
.../viewer/ReaderTransitionPage.tsx | 3 +-
src/modules/reader/services/ReaderService.ts | 3 +-
src/modules/settings/screens/Settings.tsx | 25 +--
src/modules/source/components/SourceCard.tsx | 7 +-
src/modules/source/screens/SourceMangas.tsx | 3 +-
src/modules/source/screens/Sources.tsx | 7 +-
src/modules/tracker/components/TrackManga.tsx | 3 +-
.../tracker/screens/TrackerOAuthLogin.tsx | 3 +-
src/modules/updates/screens/Updates.tsx | 8 +-
31 files changed, 292 insertions(+), 86 deletions(-)
create mode 100644 src/modules/core/AppRoute.constants.ts
diff --git a/src/App.tsx b/src/App.tsx
index 7c8247f4..5179f4b8 100644
--- a/src/App.tsx
+++ b/src/App.tsx
@@ -22,6 +22,7 @@ import { lazyLoadFallback } from '@/modules/core/utils/LazyLoad.tsx';
import { ErrorBoundary } from '@/modules/core/components/ErrorBoundary.tsx';
import { useNavBarContext } from '@/modules/navigation-bar/contexts/NavbarContext.tsx';
import { Reader } from '@/modules/reader/screens/Reader.tsx';
+import { AppRoutes } from '@/modules/core/AppRoute.constants.ts';
const { Browse } = loadable(() => import('@/modules/browse/screens/Browse.tsx'), lazyLoadFallback);
const { DownloadQueue } = loadable(() => import('@/modules/downloads/screens/DownloadQueue.tsx'), lazyLoadFallback);
@@ -113,48 +114,51 @@ const MainApp = () => {
{/* General Routes */}
- } />
- } />
-
+ } />
+ } />
+
} />
- } />
- } />
- } />
-
+ } />
+ } />
+ } />
+
} />
- } />
+ }
+ />
- } />
- } />
- } />
- } />
- } />
- } />
- } />
- } />
+ } />
+ } />
+ } />
+ } />
+ } />
+ } />
+ } />
+ } />
{/* Manga Routes */}
-
- } />
- } />
- } />
- } />
+
+ } />
+ } />
+ } />
+ } />
- } />
-
-
+ } />
+
+
} />
- } />
- } />
- } />
-
+ } />
+ } />
+ } />
+
} />
- } />
+ } />
- } />
+ } />
@@ -164,7 +168,7 @@ const MainApp = () => {
const ReaderApp = () => (
- } />
+ } />
);
@@ -181,8 +185,8 @@ export const App: React.FC = () => (
- } />
- } />
+ } />
+ } />
diff --git a/src/modules/app-updates/components/ServerUpdateChecker.tsx b/src/modules/app-updates/components/ServerUpdateChecker.tsx
index 38a6d7c4..82bb52e0 100644
--- a/src/modules/app-updates/components/ServerUpdateChecker.tsx
+++ b/src/modules/app-updates/components/ServerUpdateChecker.tsx
@@ -20,6 +20,7 @@ import { VersionUpdateInfoDialog } from '@/modules/app-updates/components/Versio
import { useMetadataServerSettings } from '@/modules/settings/services/ServerSettingsMetadata.ts';
import { useLocalStorage } from '@/modules/core/hooks/useStorage.tsx';
import { getVersion } from '@/modules/app-updates/services/AppUpdateChecker.tsx';
+import { AppRoutes } from '@/modules/core/AppRoute.constants.ts';
const disabledUpdateCheck = () => Promise.resolve();
@@ -87,7 +88,7 @@ export const ServerUpdateChecker = () => {
return null;
}
- const isAboutPage = window.location.pathname === '/settings/about';
+ const isAboutPage = window.location.pathname === AppRoutes.settings.childRoutes.about.path;
if (isAboutPage) {
return null;
}
diff --git a/src/modules/backup/screens/Backup.tsx b/src/modules/backup/screens/Backup.tsx
index 3ff8dfbf..c63da5b9 100644
--- a/src/modules/backup/screens/Backup.tsx
+++ b/src/modules/backup/screens/Backup.tsx
@@ -35,6 +35,7 @@ import { LoadingPlaceholder } from '@/modules/core/components/placeholder/Loadin
import { EmptyViewAbsoluteCentered } from '@/modules/core/components/placeholder/EmptyViewAbsoluteCentered.tsx';
import { defaultPromiseErrorHandler } from '@/lib/DefaultPromiseErrorHandler.ts';
import { ServerSettings } from '@/modules/settings/Settings.types.ts';
+import { AppRoutes } from '@/modules/core/AppRoute.constants.ts';
type BackupSettingsType = Pick;
@@ -357,7 +358,7 @@ export function Backup() {