import { lazy, useEffect, useState } from "react"; import { Redirect, Route, Switch, useLocation } from "react-router-dom"; import { convertLegacyUrl } from "@/backend/metadata/getmeta"; import { MWMediaType } from "@/backend/metadata/types/mw"; import { BannerContextProvider } from "@/hooks/useBanner"; import { Layout } from "@/setup/Layout"; import { BookmarkContextProvider } from "@/state/bookmark"; import { SettingsProvider } from "@/state/settings"; import { WatchedContextProvider } from "@/state/watched"; import { MediaView } from "@/views/media/MediaView"; import { NotFoundPage } from "@/views/notfound/NotFoundView"; import { V2MigrationView } from "@/views/other/v2Migration"; import { SearchView } from "@/views/search/SearchView"; // eslint-disable-next-line react/function-component-definition, react/prop-types const LegacyUrlView: React.FC = ({ children }) => { const location = useLocation(); const [redirectUrl, setRedirectUrl] = useState(null); useEffect(() => { // Call the conversion function and set the redirect URL if necessary convertLegacyUrl(location.pathname).then((convertedUrl) => { if (convertedUrl) { setRedirectUrl(convertedUrl); } }); }, [location.pathname]); if (redirectUrl) { return ; } // eslint-disable-next-line react/jsx-no-useless-fragment return <>{children}; }; function App() { return ( {/* functional routes */} {/* pages */} {/* other */} import("@/views/developer/DeveloperView") )} /> import("@/views/developer/VideoTesterView") )} /> {/* developer routes that can abuse workers are disabled in production */} {process.env.NODE_ENV === "development" ? ( <> import("@/views/developer/TestView") )} /> import("@/views/developer/ProviderTesterView") )} /> import("@/views/developer/EmbedTesterView") )} /> ) : null} ); } export default App;