[WIP] Migrate /internal/assetImage to Next routing

This one is a bit trickier, because it doesn't use a page layout, and we had to make some fixes in OutfitMovieLayer! Nice to get a head-start on that though :3
This commit is contained in:
Emi Matchu 2022-09-14 19:27:26 -07:00
parent 65f3b9f819
commit 1286b2e581
4 changed files with 21 additions and 13 deletions

View file

@ -0,0 +1,12 @@
import InternalAssetImagePage from "../../src/app/InternalAssetImagePage";
import type { NextPageWithLayout } from "../_app";
const InternalAssetImagePageWrapper: NextPageWithLayout = () => {
return <InternalAssetImagePage />;
};
InternalAssetImagePageWrapper.layoutComponent = ({ children }) => {
return children;
};
export default InternalAssetImagePageWrapper;

View file

@ -12,9 +12,6 @@ import WardrobePageLayout from "./WardrobePage/WardrobePageLayout";
import { loadable } from "./util"; import { loadable } from "./util";
const HomePage = loadable(() => import("./HomePage")); const HomePage = loadable(() => import("./HomePage"));
const InternalAssetImagePage = loadable(() =>
import("./InternalAssetImagePage")
);
const ItemSearchPage = loadable(() => import("./ItemSearchPage")); const ItemSearchPage = loadable(() => import("./ItemSearchPage"));
const ItemPage = loadable(() => import("./ItemPage")); const ItemPage = loadable(() => import("./ItemPage"));
const ItemTradesOfferingPage = loadable(() => const ItemTradesOfferingPage = loadable(() =>
@ -112,9 +109,6 @@ function App() {
<SupportPetAppearancesPage /> <SupportPetAppearancesPage />
</PageLayout> </PageLayout>
</Route> </Route>
<Route path="/internal/assetImage">
<InternalAssetImagePage />
</Route>
<Route path="/"> <Route path="/">
<PageLayout hideHomeLink> <PageLayout hideHomeLink>
<HomePage /> <HomePage />

View file

@ -1,8 +1,8 @@
import React from "react"; import React from "react";
import { Box, Center } from "@chakra-ui/react"; import { Box, Center } from "@chakra-ui/react";
import { useLocation } from "react-router-dom";
import * as Sentry from "@sentry/react"; import * as Sentry from "@sentry/react";
import { Global, css } from "@emotion/react"; import { Global, css } from "@emotion/react";
import { useRouter } from "next/router";
import OutfitMovieLayer from "./components/OutfitMovieLayer"; import OutfitMovieLayer from "./components/OutfitMovieLayer";
@ -36,10 +36,9 @@ function InternalAssetImagePage() {
} }
function InternalAssetImagePageContent() { function InternalAssetImagePageContent() {
const location = useLocation(); const { query } = useRouter();
const search = new URLSearchParams(location.search); const libraryUrl = query.libraryUrl;
const libraryUrl = search.get("libraryUrl"); const size = query.size ?? "600";
const size = search.get("size") || "600";
const [movieError, setMovieError] = React.useState(null); const [movieError, setMovieError] = React.useState(null);

View file

@ -7,8 +7,11 @@ import { loadImage, logAndCapture, safeImageUrl } from "../util";
// Import EaselJS and TweenJS directly into the `window` object! The bundled // Import EaselJS and TweenJS directly into the `window` object! The bundled
// scripts are built to attach themselves to `window.createjs`, and // scripts are built to attach themselves to `window.createjs`, and
// `window.createjs` is where the Neopets movie libraries expects to find them! // `window.createjs` is where the Neopets movie libraries expects to find them!
require("imports-loader?wrapper=window!easeljs/lib/easeljs"); // NOTE: If there's no window (e.g. SSR), we skip this step.
require("imports-loader?wrapper=window!tweenjs/lib/tweenjs"); if (typeof window !== "undefined") {
require("imports-loader?wrapper=window!easeljs/lib/easeljs");
require("imports-loader?wrapper=window!tweenjs/lib/tweenjs");
}
function OutfitMovieLayer({ function OutfitMovieLayer({
libraryUrl, libraryUrl,