mirror of
https://github.com/sussy-code/smov.git
synced 2024-12-29 16:07:40 +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 { 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">
|
||||||
|
|
Loading…
Reference in a new issue