From 6b537d052f5d3505d7e182929e34531ca0deabbf Mon Sep 17 00:00:00 2001 From: Matthew Zikherman Date: Wed, 20 Nov 2024 19:05:01 -0500 Subject: [PATCH] fix: use getENV instead of server side context to check IS_MOBILE --- src/Apps/Artwork/artworkRoutes.tsx | 5 +++-- src/System/Router/Utils/serverAppContext.ts | 1 - src/System/Router/__tests__/serverRouter.jest.enzyme.tsx | 1 - 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/Apps/Artwork/artworkRoutes.tsx b/src/Apps/Artwork/artworkRoutes.tsx index 9eae5861c67..9264b89137d 100644 --- a/src/Apps/Artwork/artworkRoutes.tsx +++ b/src/Apps/Artwork/artworkRoutes.tsx @@ -2,6 +2,7 @@ import loadable from "@loadable/component" import { graphql } from "react-relay" import { updateContext } from "Server/middleware/bootstrapSharifyAndContextLocalsMiddleware" import { RouteProps } from "System/Router/Route" +import { getENV } from "Utils/getENV" const ArtworkApp = loadable( () => import(/* webpackChunkName: "artworkBundle" */ "./ArtworkApp"), @@ -18,9 +19,9 @@ export const artworkRoutes: RouteProps[] = [ onClientSideRender: () => { ArtworkApp.preload() }, - prepareVariables: ({ artworkID }, { context }) => { + prepareVariables: ({ artworkID }) => { // We want to defer loading the sidebar for mobile as it is below-the-fold. - const loadSidebar = !context?.isMobile + const loadSidebar = !getENV("IS_MOBILE") return { artworkID, diff --git a/src/System/Router/Utils/serverAppContext.ts b/src/System/Router/Utils/serverAppContext.ts index 2a89d4d4471..ce474fcf8db 100644 --- a/src/System/Router/Utils/serverAppContext.ts +++ b/src/System/Router/Utils/serverAppContext.ts @@ -12,7 +12,6 @@ export const getServerAppContext = ( initialMatchingMediaQueries: res.locals.sd.IS_MOBILE ? ["xs"] : undefined, user: req.user, isEigen: req.header("User-Agent")?.match("Artsy-Mobile") != null, - isMobile: res.locals.sd.IS_MOBILE, featureFlags: res.locals.sd.FEATURE_FLAGS, userPreferences: res.locals.sd.USER_PREFERENCES, ...context, diff --git a/src/System/Router/__tests__/serverRouter.jest.enzyme.tsx b/src/System/Router/__tests__/serverRouter.jest.enzyme.tsx index a17db2fec59..f74c91bbeaf 100644 --- a/src/System/Router/__tests__/serverRouter.jest.enzyme.tsx +++ b/src/System/Router/__tests__/serverRouter.jest.enzyme.tsx @@ -179,7 +179,6 @@ describe("serverRouter", () => { "initialMatchingMediaQueries", "isEigen", "isLoggedIn", - "isMobile", "relayEnvironment", "router", "routes",