Fix isoData bug

This commit is contained in:
abias 2023-05-16 21:07:57 -04:00
parent 4f1d357b5b
commit 256420b303
3 changed files with 7 additions and 13 deletions

View file

@ -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

View file

@ -12,8 +12,11 @@ class ErrorGuard extends Component<any, any> {
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 <ErrorPage />;
} else {
return this.props.children;

View file

@ -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;
}