From 165357f44459d5d1c80add10d2bade637ee4079e Mon Sep 17 00:00:00 2001 From: Elian Doran Date: Thu, 20 Nov 2025 19:52:13 +0200 Subject: [PATCH] fix(global_menu): uncaught exception if update request fails (closes #5700) --- .../client/src/widgets/buttons/global_menu.tsx | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/apps/client/src/widgets/buttons/global_menu.tsx b/apps/client/src/widgets/buttons/global_menu.tsx index 9b36d83a5..c8c353b9c 100644 --- a/apps/client/src/widgets/buttons/global_menu.tsx +++ b/apps/client/src/widgets/buttons/global_menu.tsx @@ -26,7 +26,7 @@ export default function GlobalMenu({ isHorizontalLayout }: { isHorizontalLayout: const isVerticalLayout = !isHorizontalLayout; const parentComponent = useContext(ParentComponent); const { isUpdateAvailable, latestVersion } = useTriliumUpdateStatus(); - + return ( - + {isUpdateAvailable && <> window.open("https://github.com/TriliumNext/Trilium/releases/latest")} icon="bx bx-download" text={t("global_menu.download-update", {latestVersion})} /> } - + {!isElectron() && } ) @@ -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); }