Skip to content

armgit / jan

Public Imported from GitHub
0

Jan is an open source alternative to ChatGPT that runs 100% offline on your computer.

feat(settings): add toggle for automatic app update check

Akarshan Biswasde6115efe482
diff --git a/web-app/src/hooks/useGeneralSetting.ts b/web-app/src/hooks/useGeneralSetting.ts
index f78499cbd..f5678087e 100644
--- a/web-app/src/hooks/useGeneralSetting.ts
+++ b/web-app/src/hooks/useGeneralSetting.ts
@@ -6,10 +6,12 @@ type GeneralSettingState = {
currentLanguage: Language
spellCheckChatInput: boolean
tokenCounterCompact: boolean
+ autoUpdateCheck: boolean
huggingfaceToken?: string
setHuggingfaceToken: (token: string) => void
setSpellCheckChatInput: (value: boolean) => void
setTokenCounterCompact: (value: boolean) => void
+ setAutoUpdateCheck: (value: boolean) => void
setCurrentLanguage: (value: Language) => void
}
@@ -19,9 +21,11 @@ export const useGeneralSetting = create<GeneralSettingState>()(
currentLanguage: 'en',
spellCheckChatInput: true,
tokenCounterCompact: true,
+ autoUpdateCheck: true,
huggingfaceToken: undefined,
setSpellCheckChatInput: (value) => set({ spellCheckChatInput: value }),
setTokenCounterCompact: (value) => set({ tokenCounterCompact: value }),
+ setAutoUpdateCheck: (value) => set({ autoUpdateCheck: value }),
setCurrentLanguage: (value) => set({ currentLanguage: value }),
setHuggingfaceToken: (token) => {
set({ huggingfaceToken: token })
diff --git a/web-app/src/locales/en/settings.json b/web-app/src/locales/en/settings.json
index 301dc1b26..db3776b23 100644
--- a/web-app/src/locales/en/settings.json
+++ b/web-app/src/locales/en/settings.json
@@ -241,6 +241,8 @@
"checkForUpdates": "Check for Updates",
"checkForUpdatesDesc": "Check if a newer version of Jan is available.",
"checkingForUpdates": "Checking for updates...",
+ "autoUpdateCheck": "Automatic Update Check",
+ "autoUpdateCheckDesc": "Automatically check for updates on startup and periodically.",
"copied": "Copied",
"copyPath": "Copy Path",
"changeLocation": "Change Location",
diff --git a/web-app/src/providers/DataProvider.tsx b/web-app/src/providers/DataProvider.tsx
index 9241823bf..ebe3cb01c 100644
--- a/web-app/src/providers/DataProvider.tsx
+++ b/web-app/src/providers/DataProvider.tsx
@@ -1,6 +1,7 @@
import { useModelProvider } from '@/hooks/useModelProvider'
import { useAppUpdater } from '@/hooks/useAppUpdater'
+import { useGeneralSetting } from '@/hooks/useGeneralSetting'
import { useServiceHub } from '@/hooks/useServiceHub'
import { useEffect } from 'react'
import { useMCPServers, DEFAULT_MCP_SETTINGS } from '@/hooks/useMCPServers'
@@ -94,6 +95,7 @@ export function DataProvider() {
useModelProvider()
const { checkForUpdate } = useAppUpdater()
+ const autoUpdateCheck = useGeneralSetting((s) => s.autoUpdateCheck)
const { setServers, setSettings } = useMCPServers()
const { setAssistants } = useAssistant()
const { setThreads } = useThreads()
@@ -191,7 +193,7 @@ export function DataProvider() {
// Only check for updates if the auto updater is not disabled
// App might be distributed via other package managers
// or methods that handle updates differently
- if (isDev()) {
+ if (isDev() || !autoUpdateCheck) {
return
}
@@ -208,7 +210,7 @@ export function DataProvider() {
return () => {
clearInterval(intervalId)
}
- }, [checkForUpdate])
+ }, [checkForUpdate, autoUpdateCheck])
useEffect(() => {
events.on(AppEvent.onModelImported, () => {
diff --git a/web-app/src/routes/settings/general.tsx b/web-app/src/routes/settings/general.tsx
index bd2e5276f..8f63f92eb 100644
--- a/web-app/src/routes/settings/general.tsx
+++ b/web-app/src/routes/settings/general.tsx
@@ -42,6 +42,8 @@ function General() {
const {
spellCheckChatInput,
setSpellCheckChatInput,
+ autoUpdateCheck,
+ setAutoUpdateCheck,
huggingfaceToken,
setHuggingfaceToken,
} = useGeneralSetting()
@@ -229,23 +231,36 @@ function General() {
}
/>
{!AUTO_UPDATER_DISABLED && (
- <CardItem
- title={t('settings:general.checkForUpdates')}
- description={t('settings:general.checkForUpdatesDesc')}
- className="items-center flex-row gap-y-2"
- actions={
- <Button
- variant="secondary"
- size="sm"
- onClick={handleCheckForUpdate}
- disabled={isCheckingUpdate}
- >
- {isCheckingUpdate
- ? t('settings:general.checkingForUpdates')
- : t('settings:general.checkForUpdates')}
- </Button>
- }
- />
+ <>
+ <CardItem
+ title={t('settings:general.autoUpdateCheck')}
+ description={t('settings:general.autoUpdateCheckDesc')}
+ className="items-center flex-row gap-y-2"
+ actions={
+ <Switch
+ checked={autoUpdateCheck}
+ onCheckedChange={(e) => setAutoUpdateCheck(e)}
+ />
+ }
+ />
+ <CardItem
+ title={t('settings:general.checkForUpdates')}
+ description={t('settings:general.checkForUpdatesDesc')}
+ className="items-center flex-row gap-y-2"
+ actions={
+ <Button
+ variant="secondary"
+ size="sm"
+ onClick={handleCheckForUpdate}
+ disabled={isCheckingUpdate}
+ >
+ {isCheckingUpdate
+ ? t('settings:general.checkingForUpdates')
+ : t('settings:general.checkForUpdates')}
+ </Button>
+ }
+ />
+ </>
)}
<CardItem
title={t('common:language')}