From f31fd75efcf6971048c0111860be5c25de925075 Mon Sep 17 00:00:00 2001 From: Vendicated Date: Sun, 2 Oct 2022 02:46:41 +0200 Subject: [PATCH] UpdaterPage: Do not error if update check failed --- src/components/ErrorBoundary.tsx | 12 +++++------- src/components/ErrorCard.tsx | 21 +++++++++++++++++++++ src/components/Settings.tsx | 2 +- src/components/Updater.tsx | 32 ++++++++++++++++++++++++-------- src/utils/updater.ts | 3 +++ 5 files changed, 54 insertions(+), 16 deletions(-) create mode 100644 src/components/ErrorCard.tsx diff --git a/src/components/ErrorBoundary.tsx b/src/components/ErrorBoundary.tsx index 5946cb14a..21a315591 100644 --- a/src/components/ErrorBoundary.tsx +++ b/src/components/ErrorBoundary.tsx @@ -1,5 +1,6 @@ import Logger from "../utils/logger"; import { Card, React } from "../webpack/common"; +import { ErrorCard } from "./ErrorCard"; interface Props { fallback?: React.ComponentType>; @@ -49,12 +50,8 @@ export default class ErrorBoundary extends React.Component; return ( -

Oh no!

@@ -62,10 +59,11 @@ export default class ErrorBoundary extends React.Component -

{this.state.error}
+                    
+                        {this.state.error}
                     
- + ); } } diff --git a/src/components/ErrorCard.tsx b/src/components/ErrorCard.tsx new file mode 100644 index 000000000..d0bf8c314 --- /dev/null +++ b/src/components/ErrorCard.tsx @@ -0,0 +1,21 @@ +import { Card } from "../webpack/common"; + +interface Props { + style?: React.CSSProperties; + className?: string; +} +export function ErrorCard(props: React.PropsWithChildren) { + return ( + + {props.children} + + ); +} diff --git a/src/components/Settings.tsx b/src/components/Settings.tsx index 54e6ddb63..3b4c04af5 100644 --- a/src/components/Settings.tsx +++ b/src/components/Settings.tsx @@ -74,7 +74,7 @@ export default ErrorBoundary.wrap(function Settings() { - + ); }); diff --git a/src/utils/updater.ts b/src/utils/updater.ts index b3fa81255..e66a1497b 100644 --- a/src/utils/updater.ts +++ b/src/utils/updater.ts @@ -4,12 +4,15 @@ import { IpcRes } from './types'; export const UpdateLogger = new Logger("Updater", "white"); export let isOutdated = false; +export let updateError: any; export let changes: Record<"hash" | "author" | "message", string>[]; async function Unwrap(p: Promise>) { const res = await p; if (res.ok) return res.value; + + updateError = res.error; throw res.error; }