mirror of
https://github.com/zadam/trilium.git
synced 2025-11-21 08:04:24 +01:00
fix(global_menu): uncaught exception if update request fails (closes #5700)
This commit is contained in:
parent
d51e3de674
commit
165357f444
@ -26,7 +26,7 @@ export default function GlobalMenu({ isHorizontalLayout }: { isHorizontalLayout:
|
||||
const isVerticalLayout = !isHorizontalLayout;
|
||||
const parentComponent = useContext(ParentComponent);
|
||||
const { isUpdateAvailable, latestVersion } = useTriliumUpdateStatus();
|
||||
|
||||
|
||||
return (
|
||||
<Dropdown
|
||||
className="global-menu"
|
||||
@ -58,14 +58,14 @@ export default function GlobalMenu({ isHorizontalLayout }: { isHorizontalLayout:
|
||||
<KeyboardActionMenuItem command="showHelp" icon="bx bx-help-circle" text={t("global_menu.show_help")} />
|
||||
<KeyboardActionMenuItem command="showCheatsheet" icon="bx bxs-keyboard" text={t("global_menu.show-cheatsheet")} />
|
||||
<MenuItem command="openAboutDialog" icon="bx bx-info-circle" text={t("global_menu.about")} />
|
||||
|
||||
|
||||
{isUpdateAvailable && <>
|
||||
<FormListHeader text={t("global_menu.new-version-available")} />
|
||||
<MenuItem command={() => window.open("https://github.com/TriliumNext/Trilium/releases/latest")}
|
||||
icon="bx bx-download"
|
||||
text={t("global_menu.download-update", {latestVersion})} />
|
||||
</>}
|
||||
|
||||
|
||||
{!isElectron() && <BrowserOnlyOptions />}
|
||||
</Dropdown>
|
||||
)
|
||||
@ -221,9 +221,15 @@ function useTriliumUpdateStatus() {
|
||||
async function updateVersionStatus() {
|
||||
const RELEASES_API_URL = "https://api.github.com/repos/TriliumNext/Trilium/releases/latest";
|
||||
|
||||
const resp = await fetch(RELEASES_API_URL);
|
||||
const data = await resp.json();
|
||||
const latestVersion = data?.tag_name?.substring(1);
|
||||
let latestVersion: string | undefined = undefined;
|
||||
try {
|
||||
const resp = await fetch(RELEASES_API_URL);
|
||||
const data = await resp.json();
|
||||
latestVersion = data?.tag_name?.substring(1);
|
||||
} catch (e) {
|
||||
console.warn("Unable to fetch latest version info from GitHub releases API", e);
|
||||
}
|
||||
|
||||
setLatestVersion(latestVersion);
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user