mirror of
https://github.com/LemmyNet/lemmy-ui.git
synced 2024-11-24 07:16:19 +00:00
Fix isoData bug
This commit is contained in:
parent
4f1d357b5b
commit
256420b303
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue