diff --git a/backend/src/index.js b/backend/src/index.js index 9eaab84..51c0d8d 100644 --- a/backend/src/index.js +++ b/backend/src/index.js @@ -6,12 +6,11 @@ import { gridRoutes } from './routes/grid.js' import { settingsRoutes } from './routes/settings.js' const app = Fastify({ logger: true, trustProxy: true }) -const startedAt = Date.now() await app.register(cookie) await app.register(cors, { origin: process.env.CORS_ORIGIN || false, credentials: true }) -app.get('/health', async () => ({ status: 'healthy', version: process.env.BUILD_VERSION || String(startedAt) })) +app.get('/health', async () => ({ status: 'healthy' })) await app.register(gridRoutes) await app.register(settingsRoutes) diff --git a/frontend/index.html b/frontend/index.html index bfb178c..e8abde2 100644 --- a/frontend/index.html +++ b/frontend/index.html @@ -3,11 +3,6 @@ - - - - - Twin Optimiser diff --git a/frontend/src/App.tsx b/frontend/src/App.tsx index d7b5e8b..9c8809d 100644 --- a/frontend/src/App.tsx +++ b/frontend/src/App.tsx @@ -1,8 +1,5 @@ import { BrowserRouter, Routes, Route, Navigate } from 'react-router-dom' import { AuthGate } from './components/AuthGate' -import { UpdateBanner } from './components/UpdateBanner' -import IosInstallHint from './components/IosInstallHint' -import { useVersionCheck } from './hooks/useVersionCheck' import { Layout } from './components/Layout' import { TwinOptimiser } from './pages/TwinOptimiser' import { Settings } from './pages/Settings' @@ -21,16 +18,11 @@ function AppRoutes({ user }: { user: User }) { } export default function App() { - const updateAvailable = useVersionCheck('/twin-optimiser/health') return ( - <> - - - {user => } - - - - - + + + {user => } + + ) } diff --git a/frontend/src/components/IosInstallHint.tsx b/frontend/src/components/IosInstallHint.tsx deleted file mode 100644 index da58dd2..0000000 --- a/frontend/src/components/IosInstallHint.tsx +++ /dev/null @@ -1,89 +0,0 @@ -import { useEffect, useState } from 'react' -import { Share, ExternalLink, X } from 'lucide-react' - -function isIos() { - return /iPad|iPhone|iPod/.test(navigator.userAgent) || - // iPadOS 13+ reports as 'MacIntel' but has touch support, unlike a real Mac - (navigator.platform === 'MacIntel' && navigator.maxTouchPoints > 1) -} - -function isStandalone() { - return window.matchMedia('(display-mode: standalone)').matches || - (window.navigator as unknown as { standalone?: boolean }).standalone === true -} - -// Safari's UA also matches "Safari", so this checks for the other iOS -// browsers/in-app webviews that spoof it — none of them can add to the -// home screen; only Safari itself can. -function isNonSafariIosBrowser() { - return /CriOS|FxiOS|EdgiOS|OPiOS|mercury|GSA|DuckDuckGo|Instagram|FBAN|FBAV|Line\//.test(navigator.userAgent) -} - -/** - * iOS has no `beforeinstallprompt` API — Safari never fires it, so the - * portal's Install button (?install=1) does nothing there. This shows the - * manual steps instead: Share -> Add to Home Screen in Safari, or a prompt - * to switch to Safari first if the page was opened in another browser/app. - */ -export default function IosInstallHint() { - const [mode, setMode] = useState<'safari' | 'other' | null>(null) - - useEffect(() => { - if (!isIos() || isStandalone()) return - if (!new URLSearchParams(window.location.search).has('install')) return - setMode(isNonSafariIosBrowser() ? 'other' : 'safari') - }, []) - - if (!mode) return null - - return ( -
-
- - -
- {mode === 'safari' - ? - : } -
- - {mode === 'safari' ? ( -

- To install this app, tap the Share icon in Safari's - toolbar, then choose Add to Home Screen. -

- ) : ( -

- iOS only allows installing apps from Safari. Open this - page in Safari, then tap Share → Add to Home Screen. -

- )} -
-
- ) -} diff --git a/frontend/src/components/UpdateBanner.tsx b/frontend/src/components/UpdateBanner.tsx deleted file mode 100644 index b492c67..0000000 --- a/frontend/src/components/UpdateBanner.tsx +++ /dev/null @@ -1,44 +0,0 @@ -import { RefreshCw } from 'lucide-react' - -export function UpdateBanner({ visible }: { visible: boolean }) { - if (!visible) return null - return ( -
- A new version is available. - -
- ) -} diff --git a/frontend/src/hooks/useVersionCheck.ts b/frontend/src/hooks/useVersionCheck.ts deleted file mode 100644 index e4fed28..0000000 --- a/frontend/src/hooks/useVersionCheck.ts +++ /dev/null @@ -1,43 +0,0 @@ -import { useEffect, useState } from 'react' - -const POLL_MS = 2 * 60 * 1000 - -export function useVersionCheck(healthUrl: string) { - const [updateAvailable, setUpdateAvailable] = useState(false) - - useEffect(() => { - let seenVersion: string | null = null - - async function check() { - try { - const res = await fetch(healthUrl, { cache: 'no-store' }) - if (!res.ok) return - const data = await res.json() - const v: string | undefined = data.version - if (!v) return - if (seenVersion === null) { - seenVersion = v - } else if (v !== seenVersion) { - setUpdateAvailable(true) - } - } catch { - // network error — skip silently - } - } - - check() - const interval = setInterval(check, POLL_MS) - - function onVisible() { - if (document.visibilityState === 'visible') check() - } - document.addEventListener('visibilitychange', onVisible) - - return () => { - clearInterval(interval) - document.removeEventListener('visibilitychange', onVisible) - } - }, [healthUrl]) - - return updateAvailable -} diff --git a/frontend/src/main.tsx b/frontend/src/main.tsx index f60c9da..520b520 100644 --- a/frontend/src/main.tsx +++ b/frontend/src/main.tsx @@ -3,15 +3,6 @@ import { createRoot } from 'react-dom/client' import './index.css' import App from './App' -// When opened from the portal's install button (?install=1), trigger the -// PWA install prompt as soon as the browser offers it (Chrome/Edge only). -if (new URLSearchParams(window.location.search).has('install')) { - window.addEventListener('beforeinstallprompt', e => { - e.preventDefault() - ;(e as Event & { prompt: () => Promise }).prompt() - }, { once: true }) -} - createRoot(document.getElementById('root')!).render(