From d56686fd219e7de8ac2d168d86b9fddda0bf50c5 Mon Sep 17 00:00:00 2001 From: Faisal Amir Date: Mon, 2 Jun 2025 20:33:48 +0700 Subject: [PATCH] chore: check app update via general setting (#5167) --- web-app/src/containers/dialogs/AppUpdater.tsx | 2 +- web-app/src/routes/settings/general.tsx | 40 ++++++++++++++++++- 2 files changed, 40 insertions(+), 2 deletions(-) diff --git a/web-app/src/containers/dialogs/AppUpdater.tsx b/web-app/src/containers/dialogs/AppUpdater.tsx index f2fbf9baf..104acd377 100644 --- a/web-app/src/containers/dialogs/AppUpdater.tsx +++ b/web-app/src/containers/dialogs/AppUpdater.tsx @@ -34,7 +34,7 @@ const DialogAppUpdater = () => { return ( <> {updateState.isUpdateAvailable && ( -
+
diff --git a/web-app/src/routes/settings/general.tsx b/web-app/src/routes/settings/general.tsx index 4fc441e21..3aeb0c3b9 100644 --- a/web-app/src/routes/settings/general.tsx +++ b/web-app/src/routes/settings/general.tsx @@ -8,6 +8,7 @@ import { Card, CardItem } from '@/containers/Card' import LanguageSwitcher from '@/containers/LanguageSwitcher' import { useTranslation } from 'react-i18next' import { useGeneralSetting } from '@/hooks/useGeneralSetting' +import { useAppUpdater } from '@/hooks/useAppUpdater' import { useEffect, useState } from 'react' import { open } from '@tauri-apps/plugin-dialog' import { revealItemInDir } from '@tauri-apps/plugin-opener' @@ -59,10 +60,12 @@ const openFileTitle = (): string => { function General() { const { t } = useTranslation() const { spellCheckChatInput, setSpellCheckChatInput } = useGeneralSetting() + const { checkForUpdate } = useAppUpdater() const [janDataFolder, setJanDataFolder] = useState() const [isCopied, setIsCopied] = useState(false) const [selectedNewPath, setSelectedNewPath] = useState(null) const [isDialogOpen, setIsDialogOpen] = useState(false) + const [isCheckingUpdate, setIsCheckingUpdate] = useState(false) useEffect(() => { const fetchDataFolder = async () => { @@ -161,6 +164,22 @@ function General() { } } + const handleCheckForUpdate = async () => { + setIsCheckingUpdate(true) + try { + const update = await checkForUpdate() + if (!update) { + toast.success('You are using the latest version of Jan!') + } + // If update is available, the AppUpdater dialog will automatically show + } catch (error) { + console.error('Failed to check for updates:', error) + toast.error('Failed to check for updates. Please try again later.') + } finally { + setIsCheckingUpdate(false) + } + } + return (
@@ -175,7 +194,26 @@ function General() { v{VERSION} + + v{VERSION} + + } + /> + +
+ {isCheckingUpdate ? 'Checking...' : 'Check for Updates'} +
+ } />