Skip to content

Commit 414bc78

Browse files
authored
feat: updated to include error message (#465)
* feat: updated to include error message * docs: update changelog
1 parent 9fd4a16 commit 414bc78

File tree

2 files changed

+25
-18
lines changed

2 files changed

+25
-18
lines changed

docs/content.en/docs/release-notes/_index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ Information about release notes of Coco Server is provided here.
4444
- feat: ai assistant supports search and paging #431
4545
- feat: data sources support displaying customized icons #432
4646
- feat: add shortcut key conflict hint and reset function #442
47+
- feat: updated to include error message #465
4748

4849
### Bug fix
4950

src/components/UpdateApp/index.tsx

Lines changed: 24 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import darkIcon from "./imgs/dark-icon.png";
1111
import { useThemeStore } from "@/stores/themeStore";
1212
import { useUpdateStore } from "@/stores/updateStore";
1313
import { OpenURLWithBrowser } from "@/utils/index";
14+
import { useAppStore } from "@/stores/appStore";
1415

1516
interface State {
1617
loading?: boolean;
@@ -33,6 +34,7 @@ const UpdateApp = ({ checkUpdate, relaunchApp }: UpdateAppProps) => {
3334
const isOptional = useUpdateStore((state) => state.isOptional);
3435
const updateInfo = useUpdateStore((state) => state.updateInfo);
3536
const setUpdateInfo = useUpdateStore((state) => state.setUpdateInfo);
37+
const addError = useAppStore((state) => state.addError);
3638

3739
const state = useReactive<State>({ download: 0 });
3840

@@ -65,24 +67,28 @@ const UpdateApp = ({ checkUpdate, relaunchApp }: UpdateAppProps) => {
6567
}, [state.total, state.download]);
6668

6769
const handleDownload = async () => {
68-
if (state.loading) return;
69-
70-
state.loading = true;
71-
72-
await updateInfo?.downloadAndInstall((progress: any) => {
73-
switch (progress.event) {
74-
case "Started":
75-
state.total = progress.data.contentLength;
76-
break;
77-
case "Progress":
78-
state.download += progress.data.chunkLength;
79-
break;
80-
}
81-
});
82-
83-
state.loading = false;
84-
85-
relaunchApp();
70+
try {
71+
if (state.loading) return;
72+
73+
state.loading = true;
74+
75+
await updateInfo?.downloadAndInstall((progress: any) => {
76+
switch (progress.event) {
77+
case "Started":
78+
state.total = progress.data.contentLength;
79+
break;
80+
case "Progress":
81+
state.download += progress.data.chunkLength;
82+
break;
83+
}
84+
});
85+
86+
relaunchApp();
87+
} catch (error) {
88+
addError(String(error));
89+
} finally {
90+
state.loading = false;
91+
}
8692
};
8793

8894
const handleCancel = () => {

0 commit comments

Comments
 (0)