Skip to content
Snippets Groups Projects
Unverified Commit 650e017b authored by GyDi's avatar GyDi
Browse files

fix: when updater failed

parent 18f9d6de
No related branches found
No related tags found
No related merge requests found
import useSWR from "swr";
import { useState } from "react";
import { checkUpdate, installUpdate } from "@tauri-apps/api/updater";
import { relaunch } from "@tauri-apps/api/process";
import {
Button,
Dialog,
......@@ -10,7 +8,10 @@ import {
DialogContentText,
DialogTitle,
} from "@mui/material";
import { killSidecars } from "../../services/cmds";
import { relaunch } from "@tauri-apps/api/process";
import { checkUpdate, installUpdate } from "@tauri-apps/api/updater";
import { killSidecars, restartSidecar } from "../../services/cmds";
import Notice from "../base/base-notice";
interface Props {
open: boolean;
......@@ -29,18 +30,19 @@ const UpdateDialog = (props: Props) => {
const [uploading, setUploading] = useState(uploadingState);
const onUpdate = async () => {
setUploading(true);
uploadingState = true;
try {
setUploading(true);
uploadingState = true;
await killSidecars();
await installUpdate();
await relaunch();
} catch (error) {
console.log(error);
window.alert("Failed to upload, please try again.");
} catch (err: any) {
await restartSidecar();
Notice.error(err?.message || err.toString());
} finally {
setUploading(true);
uploadingState = true;
setUploading(false);
uploadingState = false;
}
};
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment