From: abias Date: Wed, 17 May 2023 01:07:57 +0000 (-0400) Subject: Fix isoData bug X-Git-Url: http://these/git/%7B%60/feeds/front/static/%7BpictrsAvatarThumbnail%28this.state.siteRes.site.icon%29%7D?a=commitdiff_plain;h=256420b3034c9b4eabba500991891a1641d45844;p=lemmy-ui.git Fix isoData bug --- diff --git a/src/server/index.tsx b/src/server/index.tsx index c8099cc..47262ed 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 3012154..1877188 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 c405fc5..33fe7d6 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; }