| 1 | import { desktopHost } from "./desktopHost"; |
| 2 | import { t } from "./i18n"; |
| 3 | |
| 4 | export function crashRestartButton(): HTMLButtonElement { |
| 5 | const restart = document.createElement("button"); |
| 6 | restart.className = "crash-overlay__restart"; |
| 7 | restart.textContent = t("crash.restart"); |
| 8 | restart.onclick = async () => { |
| 9 | restart.disabled = true; |
| 10 | // Resolved at click time through the host adapter, like the send action; a |
| 11 | // reload still recovers a renderer-only crash when the relaunch is refused. |
| 12 | const relaunch = desktopHost().app?.RestartApplication; |
| 13 | try { |
| 14 | if (!relaunch) throw new Error("no desktop host"); |
| 15 | await relaunch(); |
| 16 | } catch { |
| 17 | window.location.reload(); |
| 18 | } |
| 19 | }; |
| 20 | return restart; |
| 21 | } |
| 22 |