From 256420b3034c9b4eabba500991891a1641d45844 Mon Sep 17 00:00:00 2001 From: abias Date: Tue, 16 May 2023 21:07:57 -0400 Subject: [PATCH] Fix isoData bug --- src/server/index.tsx | 6 +++--- src/shared/components/common/error-guard.tsx | 3 +++ src/shared/utils.ts | 11 +---------- 3 files changed, 7 insertions(+), 13 deletions(-) diff --git a/src/server/index.tsx b/src/server/index.tsx index c8099ccd..47262ede 100644 --- a/src/server/index.tsx +++ b/src/server/index.tsx @@ -166,7 +166,7 @@ server.get("/*", async (req, res) => { } } } catch (error) { - errorPageData = getErrorRouteData(error, site); + errorPageData = getErrorPageData(error, site); } // Redirect to the 404 if there's an API error @@ -176,7 +176,7 @@ server.get("/*", async (req, res) => { if (error === "instance_is_private") { return res.redirect(`/signup`); } else { - errorPageData = getErrorRouteData(error, site); + errorPageData = getErrorPageData(error, site); } } @@ -294,7 +294,7 @@ async function fetchIconPng(iconUrl: string) { .then(blob => blob.arrayBuffer()); } -function getErrorRouteData(error: string, site?: GetSiteResponse) { +function getErrorPageData(error: string, site?: GetSiteResponse) { const errorPageData: ErrorPageData = {}; // Exact error should only be seen in a development environment. Users diff --git a/src/shared/components/common/error-guard.tsx b/src/shared/components/common/error-guard.tsx index 30121541..18771880 100644 --- a/src/shared/components/common/error-guard.tsx +++ b/src/shared/components/common/error-guard.tsx @@ -12,8 +12,11 @@ class ErrorGuard extends Component { render() { const errorPageData = this.isoData.errorPageData; const siteRes = this.isoData.site_res; + console.log("In error guard"); + console.log(errorPageData); if (errorPageData || !siteRes) { + console.log("triggered error page"); return ; } else { return this.props.children; diff --git a/src/shared/utils.ts b/src/shared/utils.ts index c405fc50..33fe7d63 100644 --- a/src/shared/utils.ts +++ b/src/shared/utils.ts @@ -1265,16 +1265,7 @@ export function isBrowser() { export function setIsoData(context: any): IsoData { // If its the browser, you need to deserialize the data from the window if (isBrowser()) { - let json = window.isoData; - let routeData = json.routeData; - let site_res = json.site_res; - - let isoData: IsoData = { - path: json.path, - site_res, - routeData, - }; - return isoData; + return window.isoData; } else return context.router.staticContext; }