From 78451f8a0e1b6733fe62dfa9dd94206b7e292fd2 Mon Sep 17 00:00:00 2001 From: Cooper Ransom Date: Sun, 17 Mar 2024 15:53:53 -0400 Subject: [PATCH] Make extension banner redirect to /onboarding/extension --- src/stores/banner/BannerLocation.tsx | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/stores/banner/BannerLocation.tsx b/src/stores/banner/BannerLocation.tsx index d73553e5..4db620e4 100644 --- a/src/stores/banner/BannerLocation.tsx +++ b/src/stores/banner/BannerLocation.tsx @@ -1,5 +1,6 @@ import { useEffect } from "react"; import { useTranslation } from "react-i18next"; +import { useLocation, useNavigate } from "react-router-dom"; import { Icon, Icons } from "@/components/Icon"; import { ExtensionStatus } from "@/setup/Layout"; @@ -49,11 +50,11 @@ export function ExtensionBanner(props: { location?: string; extensionState: ExtensionStatus; }) { + const navigate = useNavigate(); const setLocation = useBannerStore((s) => s.setLocation); const currentLocation = useBannerStore((s) => s.location); - const extensionPage = - "https://chromewebstore.google.com/detail/movie-web-extension/hoffoikpiofojilgpofjhnkkamfnnhmm"; const loc = props.location ?? null; + const { pathname } = useLocation(); useEffect(() => { if (!loc) return; @@ -63,7 +64,8 @@ export function ExtensionBanner(props: { }; }, [setLocation, loc]); - if (currentLocation !== loc) return null; + if (currentLocation !== loc || pathname === "/onboarding/extension") + return null; // Show the banner with a 40% chance if (Math.random() < 0.4) { @@ -87,7 +89,7 @@ export function ExtensionBanner(props: { return (
window.open(extensionPage, "_blank")} + onClick={() => navigate("/onboarding/extension")} style={{ cursor: "pointer" }} >