fix: when updater failed
This commit is contained in:
parent
18f9d6dec5
commit
650e017b72
@ -1,7 +1,5 @@
|
|||||||
import useSWR from "swr";
|
import useSWR from "swr";
|
||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
import { checkUpdate, installUpdate } from "@tauri-apps/api/updater";
|
|
||||||
import { relaunch } from "@tauri-apps/api/process";
|
|
||||||
import {
|
import {
|
||||||
Button,
|
Button,
|
||||||
Dialog,
|
Dialog,
|
||||||
@ -10,7 +8,10 @@ import {
|
|||||||
DialogContentText,
|
DialogContentText,
|
||||||
DialogTitle,
|
DialogTitle,
|
||||||
} from "@mui/material";
|
} 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 {
|
interface Props {
|
||||||
open: boolean;
|
open: boolean;
|
||||||
@ -29,18 +30,19 @@ const UpdateDialog = (props: Props) => {
|
|||||||
const [uploading, setUploading] = useState(uploadingState);
|
const [uploading, setUploading] = useState(uploadingState);
|
||||||
|
|
||||||
const onUpdate = async () => {
|
const onUpdate = async () => {
|
||||||
|
setUploading(true);
|
||||||
|
uploadingState = true;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
setUploading(true);
|
|
||||||
uploadingState = true;
|
|
||||||
await killSidecars();
|
await killSidecars();
|
||||||
await installUpdate();
|
await installUpdate();
|
||||||
await relaunch();
|
await relaunch();
|
||||||
} catch (error) {
|
} catch (err: any) {
|
||||||
console.log(error);
|
await restartSidecar();
|
||||||
window.alert("Failed to upload, please try again.");
|
Notice.error(err?.message || err.toString());
|
||||||
} finally {
|
} finally {
|
||||||
setUploading(true);
|
setUploading(false);
|
||||||
uploadingState = true;
|
uploadingState = false;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user