fix(landing): masque « Ouvrir dans l'application » dans l'app native (#103) #117
1 changed files with 19 additions and 9 deletions
|
|
@ -1,3 +1,4 @@
|
|||
import { Capacitor } from "@capacitor/core";
|
||||
import { CalendarDays, HeartPulse, Smartphone, Sparkles, Users } from "lucide-react";
|
||||
import type { ReactNode } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
|
|
@ -29,6 +30,13 @@ export function LandingPage() {
|
|||
// whether the viewport is narrow (a resized desktop window shouldn't
|
||||
// attempt a scheme navigation just because it's a small window).
|
||||
const isMobile = isAndroidPhoneBrowser();
|
||||
// ...but the Capacitor WebView's UA *also* contains "Android"/"Mobile",
|
||||
// so `isMobile` alone is true inside the packaged app too — where
|
||||
// "Ouvrir dans l'application" is nonsense (you're already in it; tapping
|
||||
// it just tries to re-launch via the scheme, fails, and lands on
|
||||
// `/telecharger`). `canOfferApp` is the real "a phone *browser* where
|
||||
// pushing the native app is worthwhile" flag (issue #103).
|
||||
const canOfferApp = isMobile && !Capacitor.isNativePlatform();
|
||||
|
||||
function handleOpenApp() {
|
||||
attemptOpenNativeApp({ onFallback: () => navigate("/telecharger") });
|
||||
|
|
@ -69,7 +77,7 @@ export function LandingPage() {
|
|||
* this button doesn't render at all (see the plain `/telecharger`
|
||||
* link below instead, replacing the old direct-APK link).
|
||||
*/}
|
||||
{isMobile && (
|
||||
{canOfferApp && (
|
||||
<button
|
||||
type="button"
|
||||
className="landing__cta landing__cta--primary"
|
||||
|
|
@ -81,7 +89,7 @@ export function LandingPage() {
|
|||
)}
|
||||
<Link
|
||||
className={
|
||||
isMobile
|
||||
canOfferApp
|
||||
? "landing__cta landing__cta--secondary"
|
||||
: "landing__cta landing__cta--primary"
|
||||
}
|
||||
|
|
@ -94,14 +102,16 @@ export function LandingPage() {
|
|||
</Link>
|
||||
</div>
|
||||
{/*
|
||||
* Desktop only — a scheme-open attempt (the mobile button above)
|
||||
* has no meaning here. Routed through `/telecharger` (the same
|
||||
* fallback page a failed mobile attempt lands on) rather than
|
||||
* linking `${API_BASE_URL}/mobile/download` directly, so "get
|
||||
* the app" has exactly one canonical destination app-wide
|
||||
* instead of two slightly different mechanisms to keep in sync.
|
||||
* Desktop browser only — a phone browser gets the scheme-open
|
||||
* button above instead, and inside the packaged app "get the app"
|
||||
* is meaningless (a tablet Capacitor WebView can lack "Mobile" in
|
||||
* its UA, so `!isMobile` isn't enough on its own — issue #103).
|
||||
* Routed through `/telecharger` (the same fallback page a failed
|
||||
* mobile attempt lands on) rather than linking
|
||||
* `${API_BASE_URL}/mobile/download` directly, so "get the app"
|
||||
* has exactly one canonical destination app-wide.
|
||||
*/}
|
||||
{!isMobile && (
|
||||
{!isMobile && !Capacitor.isNativePlatform() && (
|
||||
<Link className="landing__mobile-link" to="/telecharger">
|
||||
<Smartphone aria-hidden />
|
||||
{t("landing.hero.mobileDownload")}
|
||||
|
|
|
|||
Loading…
Reference in a new issue