diff options
author | Vendicated <vendicated@riseup.net> | 2022-10-02 02:46:41 +0200 |
---|---|---|
committer | Vendicated <vendicated@riseup.net> | 2022-10-02 02:46:41 +0200 |
commit | f31fd75efcf6971048c0111860be5c25de925075 (patch) | |
tree | f63e867d64743ffa816e56536163045dfd87ee3e /src/components/Updater.tsx | |
parent | 57d586fab73814a3778303c7a78c55c785e62af0 (diff) | |
download | Vencord-f31fd75efcf6971048c0111860be5c25de925075.tar.gz Vencord-f31fd75efcf6971048c0111860be5c25de925075.tar.bz2 Vencord-f31fd75efcf6971048c0111860be5c25de925075.zip |
UpdaterPage: Do not error if update check failed
Diffstat (limited to 'src/components/Updater.tsx')
-rw-r--r-- | src/components/Updater.tsx | 32 |
1 files changed, 24 insertions, 8 deletions
diff --git a/src/components/Updater.tsx b/src/components/Updater.tsx index 947ce43..7e4b2a7 100644 --- a/src/components/Updater.tsx +++ b/src/components/Updater.tsx @@ -1,10 +1,11 @@ import gitHash from "git-hash"; -import { changes, checkForUpdates, getRepo, rebuild, update, UpdateLogger } from "../utils/updater"; +import { changes, checkForUpdates, getRepo, rebuild, update, UpdateLogger, updateError } from '../utils/updater'; import { React, Forms, Button, Margins, Alerts, Card, Parser, Toasts } from '../webpack/common'; import { Flex } from "./Flex"; import { useAwaiter } from '../utils/misc'; import { Link } from "./Link"; import ErrorBoundary from "./ErrorBoundary"; +import { ErrorCard } from "./ErrorCard"; function withDispatcher(dispatcher: React.Dispatch<React.SetStateAction<boolean>>, action: () => any) { @@ -31,7 +32,11 @@ function withDispatcher(dispatcher: React.Dispatch<React.SetStateAction<boolean> } Alerts.show({ title: "Oops!", - body: err.split("\n").map(line => <div>{Parser.parse(line)}</div>) + body: ( + <ErrorCard> + {err.split("\n").map(line => <div>{Parser.parse(line)}</div>)} + </ErrorCard> + ) }); } finally { @@ -51,7 +56,7 @@ export default ErrorBoundary.wrap(function Updater() { UpdateLogger.error("Failed to retrieve repo", err); }, [err]); - const isOutdated = updates.length > 0; + const isOutdated = updates?.length > 0; return ( <Forms.FormSection tag="h1" title="Vencord Updater"> @@ -67,11 +72,22 @@ export default ErrorBoundary.wrap(function Updater() { <Forms.FormTitle tag="h5">Updates</Forms.FormTitle> - <Forms.FormText className={Margins.marginBottom8}> - {updates.length ? `There are ${updates.length} Updates` : "Up to Date!"} - </Forms.FormText> + {!updates && updateError ? ( + <> + <Forms.FormText>Failed to check updates. Check the console for more info</Forms.FormText> + <ErrorCard style={{ padding: "1em" }}> + <p>{updateError.stderr || updateError.stdout || "An unknown error occurred"}</p> + </ErrorCard> + </> + ) : + ( + <Forms.FormText className={Margins.marginBottom8}> + {isOutdated ? `There are ${updates.length} Updates` : "Up to Date!"} + </Forms.FormText> + ) + } - {updates.length > 0 && ( + {isOutdated && ( <Card style={{ padding: ".5em" }}> {updates.map(({ hash, author, message }) => ( <div> @@ -139,6 +155,6 @@ export default ErrorBoundary.wrap(function Updater() { Check for Updates </Button> </Flex> - </Forms.FormSection> + </Forms.FormSection > ); }); |