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:
parent
fe14f61525
commit
78451f8a0e
1 changed files with 6 additions and 4 deletions
|
@ -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 (
|
||||
<div
|
||||
onClick={() => window.open(extensionPage, "_blank")}
|
||||
onClick={() => navigate("/onboarding/extension")}
|
||||
style={{ cursor: "pointer" }}
|
||||
>
|
||||
<Banner id="extension" type="info">
|
||||
|
|
Loading…
Reference in a new issue