feat(waiter): install-app dialog (first visit) + "Εγκατάσταση εφαρμογής" in the side drawer

Replaces the thin bottom banner with a proper dialog (taller than wide):
app icon, four reasons to install (starts instantly, survives WiFi drops,
encrypted link, finds the server + updates itself), the three install
steps, "Λήψη εφαρμογής" and "Όχι τώρα". It opens by itself once, on the
first browser visit; closing it or tapping download marks it seen for good
(previously a 7-day dismissal, and once gone there was no way back).
Afterwards it is reachable from the side drawer, right above Settings.

Offered only where it makes sense: a browser on an Android phone (never in
the native app, on iPhones or desktops) and only if this venue's server
actually serves the APK (HEAD /downloads/xenia-waiter.apk, checked once).

Verified in Edge emulating Android / iPhone / desktop against the prod
build: auto-opens once, "Όχι τώρα" persists across reloads, drawer item
above Settings reopens it, not offered on iPhone/desktop or when the
server has no APK.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-09-28 22:01:05 +03:00
co-authored by Claude Opus 5.5
parent 251cac9807
commit a349043abb
5 changed files with 203 additions and 101 deletions
@@ -0,0 +1,59 @@
import { create } from 'zustand'
import { deliveryMode } from '../config/server'
/**
* "Install the Android app" dialog (browser mode only).
*
* It opens by itself once, the first time an Android phone opens the waiter app
* in a browser, and only if this venue's server actually serves the APK. Closing it or tapping
* download marks it as seen for good; after that it's reachable from the side
* drawer ("Εγκατάσταση εφαρμογής", above Settings).
*/
export const APK_URL = import.meta.env.VITE_APP_DOWNLOAD_URL || '/downloads/xenia-waiter.apk'
const SEEN_KEY = 'install-app-prompt-seen'
/** Browser on an Android phone — the only place an APK is useful. */
export function canOfferApp() {
return deliveryMode() !== 'native' && /Android/i.test(navigator.userAgent)
}
let availability = null
/** Resolves true if this server serves the APK (checked once per page load). */
export function apkAvailable() {
if (!canOfferApp()) return Promise.resolve(false)
availability ??= fetch(APK_URL, { method: 'HEAD' })
// nginx answers a real 404 for a missing file under /downloads/
.then(r => r.ok && !(r.headers.get('content-type') || '').includes('text/html'))
.catch(() => false)
return availability
}
function wasSeen() {
try {
return localStorage.getItem(SEEN_KEY) === '1'
} catch {
return false
}
}
const useInstallPromptStore = create((set) => ({
open: false,
show: () => set({ open: true }),
/** Close and never open by itself again. */
dismiss: () => {
try {
localStorage.setItem(SEEN_KEY, '1')
} catch {
// storage unavailable — it may open once more on the next visit
}
set({ open: false })
},
/** First visit: open once if the APK is there and the dialog wasn't seen yet. */
autoOpen: async () => {
if (wasSeen() || !(await apkAvailable())) return
set({ open: true })
},
}))
export default useInstallPromptStore