Merge pull request 'fix(landing): masque « Ouvrir dans l'application » dans l'app native (#103)' (#117) from fix/landing-hide-open-app-in-native into main
Some checks failed
Some checks failed
This commit is contained in:
commit
6828809081
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 { CalendarDays, HeartPulse, Smartphone, Sparkles, Users } from "lucide-react";
|
||||||
import type { ReactNode } from "react";
|
import type { ReactNode } from "react";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
|
|
@ -29,6 +30,13 @@ export function LandingPage() {
|
||||||
// whether the viewport is narrow (a resized desktop window shouldn't
|
// whether the viewport is narrow (a resized desktop window shouldn't
|
||||||
// attempt a scheme navigation just because it's a small window).
|
// attempt a scheme navigation just because it's a small window).
|
||||||
const isMobile = isAndroidPhoneBrowser();
|
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() {
|
function handleOpenApp() {
|
||||||
attemptOpenNativeApp({ onFallback: () => navigate("/telecharger") });
|
attemptOpenNativeApp({ onFallback: () => navigate("/telecharger") });
|
||||||
|
|
@ -69,7 +77,7 @@ export function LandingPage() {
|
||||||
* this button doesn't render at all (see the plain `/telecharger`
|
* this button doesn't render at all (see the plain `/telecharger`
|
||||||
* link below instead, replacing the old direct-APK link).
|
* link below instead, replacing the old direct-APK link).
|
||||||
*/}
|
*/}
|
||||||
{isMobile && (
|
{canOfferApp && (
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
className="landing__cta landing__cta--primary"
|
className="landing__cta landing__cta--primary"
|
||||||
|
|
@ -81,7 +89,7 @@ export function LandingPage() {
|
||||||
)}
|
)}
|
||||||
<Link
|
<Link
|
||||||
className={
|
className={
|
||||||
isMobile
|
canOfferApp
|
||||||
? "landing__cta landing__cta--secondary"
|
? "landing__cta landing__cta--secondary"
|
||||||
: "landing__cta landing__cta--primary"
|
: "landing__cta landing__cta--primary"
|
||||||
}
|
}
|
||||||
|
|
@ -94,14 +102,16 @@ export function LandingPage() {
|
||||||
</Link>
|
</Link>
|
||||||
</div>
|
</div>
|
||||||
{/*
|
{/*
|
||||||
* Desktop only — a scheme-open attempt (the mobile button above)
|
* Desktop browser only — a phone browser gets the scheme-open
|
||||||
* has no meaning here. Routed through `/telecharger` (the same
|
* button above instead, and inside the packaged app "get the app"
|
||||||
* fallback page a failed mobile attempt lands on) rather than
|
* is meaningless (a tablet Capacitor WebView can lack "Mobile" in
|
||||||
* linking `${API_BASE_URL}/mobile/download` directly, so "get
|
* its UA, so `!isMobile` isn't enough on its own — issue #103).
|
||||||
* the app" has exactly one canonical destination app-wide
|
* Routed through `/telecharger` (the same fallback page a failed
|
||||||
* instead of two slightly different mechanisms to keep in sync.
|
* 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">
|
<Link className="landing__mobile-link" to="/telecharger">
|
||||||
<Smartphone aria-hidden />
|
<Smartphone aria-hidden />
|
||||||
{t("landing.hero.mobileDownload")}
|
{t("landing.hero.mobileDownload")}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue