1
0
Fork 0
mirror of https://github.com/sussy-code/smov.git synced 2025-01-04 16:47:40 +01:00

Replace src/utils/setup/App.tsx with src/setup/App.tsx & merge movie-web/dev

This commit is contained in:
Cooper Ransom 2024-03-07 11:42:17 -05:00
parent 4a6395842e
commit 230b86ea8a
2 changed files with 83 additions and 68 deletions

View file

@ -1,4 +1,3 @@
import { Analytics } from "@vercel/analytics/react";
import { ReactElement, Suspense, lazy, useEffect, useState } from "react"; import { ReactElement, Suspense, lazy, useEffect, useState } from "react";
import { lazyWithPreload } from "react-lazy-with-preload"; import { lazyWithPreload } from "react-lazy-with-preload";
import { import {
@ -174,7 +173,6 @@ function App() {
{showDowntime && ( {showDowntime && (
<MaintenancePage onHomeButtonClick={handleButtonClick} /> <MaintenancePage onHomeButtonClick={handleButtonClick} />
)} )}
<Analytics />
</Layout> </Layout>
); );
} }

View file

@ -1,4 +1,4 @@
import { ReactElement, Suspense, lazy, useEffect } from "react"; import { ReactElement, Suspense, lazy, useEffect, useState } from "react";
import { lazyWithPreload } from "react-lazy-with-preload"; import { lazyWithPreload } from "react-lazy-with-preload";
import { import {
Navigate, Navigate,
@ -16,6 +16,7 @@ import { AboutPage } from "@/pages/About";
import { AdminPage } from "@/pages/admin/AdminPage"; import { AdminPage } from "@/pages/admin/AdminPage";
import VideoTesterView from "@/pages/developer/VideoTesterView"; import VideoTesterView from "@/pages/developer/VideoTesterView";
import { DmcaPage, shouldHaveDmcaPage } from "@/pages/Dmca"; import { DmcaPage, shouldHaveDmcaPage } from "@/pages/Dmca";
import MaintenancePage from "@/pages/errors/MaintenancePage";
import { NotFoundPage } from "@/pages/errors/NotFoundPage"; import { NotFoundPage } from "@/pages/errors/NotFoundPage";
import { HomePage } from "@/pages/HomePage"; import { HomePage } from "@/pages/HomePage";
import { LoginPage } from "@/pages/Login"; import { LoginPage } from "@/pages/Login";
@ -23,6 +24,7 @@ import { OnboardingPage } from "@/pages/onboarding/Onboarding";
import { OnboardingExtensionPage } from "@/pages/onboarding/OnboardingExtension"; import { OnboardingExtensionPage } from "@/pages/onboarding/OnboardingExtension";
import { OnboardingProxyPage } from "@/pages/onboarding/OnboardingProxy"; import { OnboardingProxyPage } from "@/pages/onboarding/OnboardingProxy";
import { RegisterPage } from "@/pages/Register"; import { RegisterPage } from "@/pages/Register";
import { SupportPage } from "@/pages/Support";
import { Layout } from "@/setup/Layout"; import { Layout } from "@/setup/Layout";
import { useHistoryListener } from "@/stores/history"; import { useHistoryListener } from "@/stores/history";
import { LanguageProvider } from "@/stores/language"; import { LanguageProvider } from "@/stores/language";
@ -83,19 +85,34 @@ function QueryView() {
return null; return null;
} }
// Duplicate of @/src/setup/App.tsx
function App() { function App() {
useHistoryListener(); useHistoryListener();
useOnlineListener(); useOnlineListener();
const maintenance = false; // Changing to true shows maintenance page
const [showDowntime, setShowDowntime] = useState(maintenance);
const handleButtonClick = () => {
setShowDowntime(false);
};
useEffect(() => {
const sessionToken = sessionStorage.getItem("downtimeToken");
if (!sessionToken && maintenance) {
setShowDowntime(true);
sessionStorage.setItem("downtimeToken", "true");
}
}, [setShowDowntime, maintenance]);
return ( return (
<Layout> <Layout>
<LanguageProvider /> <LanguageProvider />
{!showDowntime && (
<Routes> <Routes>
{/* functional routes */} {/* functional routes */}
<Route path="/s/:query" element={<QuickSearch />} /> <Route path="/s/:query" element={<QuickSearch />} />
<Route path="/search/:type" element={<Navigate to="/browse" />} /> <Route path="/search/:type" element={<Navigate to="/browse" />} />
<Route path="/search/:type/:query?" element={<QueryView />} /> <Route path="/search/:type/:query?" element={<QueryView />} />
{/* pages */} {/* pages */}
<Route <Route
path="/media/:media" path="/media/:media"
@ -128,11 +145,11 @@ function App() {
element={<OnboardingExtensionPage />} element={<OnboardingExtensionPage />}
/> />
<Route path="/onboarding/proxy" element={<OnboardingProxyPage />} /> <Route path="/onboarding/proxy" element={<OnboardingProxyPage />} />
{shouldHaveDmcaPage() ? ( {shouldHaveDmcaPage() ? (
<Route path="/dmca" element={<DmcaPage />} /> <Route path="/dmca" element={<DmcaPage />} />
) : null} ) : null}
{/* Support page */}
<Route path="/support" element={<SupportPage />} />
{/* Settings page */} {/* Settings page */}
<Route <Route
path="/settings" path="/settings"
@ -142,10 +159,8 @@ function App() {
</Suspense> </Suspense>
} }
/> />
{/* admin routes */} {/* admin routes */}
<Route path="/admin" element={<AdminPage />} /> <Route path="/admin" element={<AdminPage />} />
{/* other */} {/* other */}
<Route path="/dev" element={<DeveloperPage />} /> <Route path="/dev" element={<DeveloperPage />} />
<Route path="/dev/video" element={<VideoTesterView />} /> <Route path="/dev/video" element={<VideoTesterView />} />
@ -155,8 +170,10 @@ function App() {
) : null} ) : null}
<Route path="*" element={<NotFoundPage />} /> <Route path="*" element={<NotFoundPage />} />
</Routes> </Routes>
)}
{showDowntime && (
<MaintenancePage onHomeButtonClick={handleButtonClick} />
)}
</Layout> </Layout>
); );
} }
export default App;