mirror of
https://github.com/LCE-Hub/LCE-Emerald-Launcher.git
synced 2026-09-23 08:32:51 +00:00
feat: download retry and error surfacing (#95)
This commit is contained in:
@@ -364,9 +364,17 @@ export function useGameManager({
|
||||
const unlistenRunner = TauriService.onRunnerDownloadProgress((p) =>
|
||||
setRunnerDownloadProgress(p),
|
||||
);
|
||||
const unlistenError = TauriService.onBackendError((msg) => {
|
||||
setError(msg);
|
||||
});
|
||||
const unlistenRetry = TauriService.onDownloadRetry((attempt) => {
|
||||
setError(`Download failed, retrying (${attempt}/3)...`);
|
||||
});
|
||||
return () => {
|
||||
unlistenDownload.then((u) => u());
|
||||
unlistenRunner.then((u) => u());
|
||||
unlistenError.then((u) => u());
|
||||
unlistenRetry.then((u) => u());
|
||||
};
|
||||
}, [customEditions, checkInstalls]);
|
||||
|
||||
|
||||
@@ -206,6 +206,18 @@ export class TauriService {
|
||||
);
|
||||
}
|
||||
|
||||
static onBackendError(callback: (message: string) => void) {
|
||||
return listen<string>("backend-error", (event) =>
|
||||
callback(event.payload),
|
||||
);
|
||||
}
|
||||
|
||||
static onDownloadRetry(callback: (attempt: number) => void) {
|
||||
return listen<number>("download-retry", (event) =>
|
||||
callback(event.payload),
|
||||
);
|
||||
}
|
||||
|
||||
static async openUrl(url: string): Promise<void> {
|
||||
return invoke("plugin:opener|open_url", { url });
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user