]> Untitled Git - lemmy-ui.git/commitdiff
Fix error page not showing when site not fetched and adjust styles
authorabias <abias1122@gmail.com>
Mon, 15 May 2023 03:01:39 +0000 (23:01 -0400)
committerabias <abias1122@gmail.com>
Mon, 15 May 2023 03:01:39 +0000 (23:01 -0400)
src/server/index.tsx
src/shared/components/app/error-page.tsx
src/shared/components/common/auth-guard.tsx

index 26f5cf90a7281c025a6b98c313c6f8d6d830e289..5e9b31932ae41da7409ca5bb22f1bc8f95d5f599 100644 (file)
@@ -167,7 +167,7 @@ server.get("/*", async (req, res) => {
         }
       }
     } catch (error) {
-      routeData = [getErrorRouteData(error)];
+      routeData = getErrorRouteData(error, site);
     }
 
     // Redirect to the 404 if there's an API error
@@ -177,13 +177,10 @@ server.get("/*", async (req, res) => {
       if (error === "instance_is_private") {
         return res.redirect(`/signup`);
       } else {
-        routeData = [getErrorRouteData(error, site)];
+        routeData = getErrorRouteData(error, site);
       }
     }
 
-    console.log("Route Data");
-    console.log(routeData);
-
     const isoData: IsoDataOptionalSite = {
       path,
       site_res: site,
index e093463bc8d2cf1c3e525c972cdb488b0a34bb49..7c7bfceb4ac1390b07e89296dfab64832b079a02 100644 (file)
@@ -16,31 +16,51 @@ export class ErrorPage extends Component<any, any> {
     return (
       <div className="container-lg text-center">
         <h1>{errorPageData ? "Error!" : "Page Not Found"}</h1>
-        <p>
-          {errorPageData
-            ? 'There was an error on the server. Try refreshing your browser. If that doesn\'t work, come back at a later time. If the problem persists, <a href="https://github.com/LemmyNet/lemmy/issues">consider opening an issue.</a>'
-            : "The page you are looking for does not exist"}
+        <p className="p-4">
+          {errorPageData ? (
+            <>
+              <span>
+                There was an error on the server. Try refreshing your browser.
+                If that doesn&apos;t work, come back at a later time. If the
+                problem persists,
+              </span>{" "}
+              <a href="https://github.com/LemmyNet/lemmy/issues">
+                consider opening an issue.
+              </a>
+            </>
+          ) : (
+            "The page you are looking for does not exist."
+          )}
         </p>
         {!errorPageData && (
-          <Link to="/">Click here to return to your home page</Link>
+          <Link to="/" replace>
+            Click here to return to your home page.
+          </Link>
         )}
         {errorPageData?.adminMatrixIds &&
           errorPageData.adminMatrixIds.length > 0 && (
-            <div>
+            <>
               <div>
                 If you would like to reach out to one of{" "}
                 {this.isoData.site_res?.site_view.site.name ?? "this instance"}
                 &apos;s admins for support, try the following Matrix addresses:
               </div>
-              <ul>
+              <ul className="mx-auto mt-2" style={{ width: "fit-content" }}>
                 {errorPageData.adminMatrixIds.map(matrixId => (
-                  <li key={matrixId}>{matrixId}</li>
+                  <li key={matrixId} className="text-info">
+                    {matrixId}
+                  </li>
                 ))}
               </ul>
-            </div>
+            </>
           )}
         {errorPageData?.error && (
-          <code className="text-start">{errorPageData.error}</code>
+          <code
+            style={{ "text-align": "start" }}
+            className="d-block bg-dark text-light p-2 mt-4"
+          >
+            {errorPageData.error}
+          </code>
         )}
       </div>
     );
index bdddec787b502c0ac19c0be515a7a5d22c00c0ae..e79a541eaf7ff69c56d62f9428d8359a4e41fdb8 100644 (file)
@@ -6,7 +6,7 @@ function AuthGuard(props: { children?: InfernoNode }) {
   if (!UserService.Instance.myUserInfo) {
     return <Redirect to="/login" />;
   } else {
-    return <>{props.children}</>;
+    return props.children;
   }
 }