1
0
Fork 0
mirror of https://github.com/sussy-code/smov.git synced 2024-12-20 14:37:43 +01:00

Make extension banner redirect to /onboarding/extension

This commit is contained in:
Cooper Ransom 2024-03-17 15:53:53 -04:00
parent fe14f61525
commit 78451f8a0e

View file

@ -1,5 +1,6 @@
import { useEffect } from "react"; import { useEffect } from "react";
import { useTranslation } from "react-i18next"; import { useTranslation } from "react-i18next";
import { useLocation, useNavigate } from "react-router-dom";
import { Icon, Icons } from "@/components/Icon"; import { Icon, Icons } from "@/components/Icon";
import { ExtensionStatus } from "@/setup/Layout"; import { ExtensionStatus } from "@/setup/Layout";
@ -49,11 +50,11 @@ export function ExtensionBanner(props: {
location?: string; location?: string;
extensionState: ExtensionStatus; extensionState: ExtensionStatus;
}) { }) {
const navigate = useNavigate();
const setLocation = useBannerStore((s) => s.setLocation); const setLocation = useBannerStore((s) => s.setLocation);
const currentLocation = useBannerStore((s) => s.location); const currentLocation = useBannerStore((s) => s.location);
const extensionPage =
"https://chromewebstore.google.com/detail/movie-web-extension/hoffoikpiofojilgpofjhnkkamfnnhmm";
const loc = props.location ?? null; const loc = props.location ?? null;
const { pathname } = useLocation();
useEffect(() => { useEffect(() => {
if (!loc) return; if (!loc) return;
@ -63,7 +64,8 @@ export function ExtensionBanner(props: {
}; };
}, [setLocation, loc]); }, [setLocation, loc]);
if (currentLocation !== loc) return null; if (currentLocation !== loc || pathname === "/onboarding/extension")
return null;
// Show the banner with a 40% chance // Show the banner with a 40% chance
if (Math.random() < 0.4) { if (Math.random() < 0.4) {
@ -87,7 +89,7 @@ export function ExtensionBanner(props: {
return ( return (
<div <div
onClick={() => window.open(extensionPage, "_blank")} onClick={() => navigate("/onboarding/extension")}
style={{ cursor: "pointer" }} style={{ cursor: "pointer" }}
> >
<Banner id="extension" type="info"> <Banner id="extension" type="info">