Jan is an open source alternative to ChatGPT that runs 100% offline on your computer.
feat(linux): refetch titlebar button layout on window focus
Akarshan Biswas756552a71c61
diff --git a/web-app/src/components/WindowControls.tsx b/web-app/src/components/WindowControls.tsxindex 124dc6d93..be3ba03ce 100644--- a/web-app/src/components/WindowControls.tsx+++ b/web-app/src/components/WindowControls.tsx@@ -1,4 +1,4 @@-import { useEffect, useState } from 'react'+import { useCallback, useEffect, useState } from 'react'import { Minus, Square, X } from 'lucide-react'import { getCurrentWebviewWindow } from '@tauri-apps/api/webviewWindow'import { invoke } from '@tauri-apps/api/core'@@ -16,12 +16,25 @@ export const WindowControls = () => {const appWindow = getCurrentWebviewWindow()const [layout, setLayout] = useState<TitlebarLayout>(DEFAULT_LAYOUT)- useEffect(() => {+ const refresh = useCallback(() => {invoke<TitlebarLayout>('get_titlebar_layout').then((l) => setLayout(l)).catch(() => setLayout(DEFAULT_LAYOUT))}, [])+ // Refetch on focus so changes made in the DE's settings (KDE/GNOME) while Jan+ // was unfocused are picked up without a restart.+ useEffect(() => {+ refresh()+ if (!IS_LINUX) return+ const unlisten = appWindow.onFocusChanged(({ payload: focused }) => {+ if (focused) refresh()+ })+ return () => {+ unlisten.then((fn) => fn())+ }+ }, [appWindow, refresh])+const actions: Record<ButtonId, () => Promise<void>> = {minimize: () => appWindow.minimize(),maximize: () => appWindow.toggleMaximize(),