Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
andreacioni committed May 1, 2024
1 parent 5ee8c26 commit cf6f35c
Showing 1 changed file with 25 additions and 21 deletions.
46 changes: 25 additions & 21 deletions webapp/src/app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,7 @@ export default function Home() {
const [username, setUsername] = useState<string>();
const [password, setPassword] = useState<string>();
const [qrCodeState, setQrCodeState] = useState<QrCodeState>("generating");
const [domainPopupChecked, setDomainPopupChecked] =
useState<boolean>(false);
const [domainPopupChecked, setDomainPopupChecked] = useState<boolean>(false);

const howToRef = useRef<any>();
const howItWorksRef = useRef<any>();
Expand Down Expand Up @@ -90,7 +89,7 @@ export default function Home() {
useEffect(() => {
const goToNewDomain = async () => {
window.location.href = "https://keelink.fly.dev";
}
};
const confirmReadPopup = async () => {
return await swal.fire({
title: "🏗️ Domain moving 🏗️",
Expand All @@ -107,25 +106,30 @@ export default function Home() {
};

const showPopup =
(localStorage.getItem(LOCAL_STORAGE_DOMAIN_CHANGED_CHECKED) !== "true") && !document.URL.includes("keelink.fly.dev");

if (
showPopup &&
(document.URL.includes("keelink.cloud") ||
document.URL.includes("localhost"))
) {
confirmReadPopup().then(({ value, isConfirmed }) => {
if (isConfirmed) {
if (value) {
localStorage.setItem(LOCAL_STORAGE_DOMAIN_CHANGED_CHECKED, "true");
document.URL.includes("keelink.cloud") ||
document.URL.includes("localhost");

const automaticRedirectAccepted =
localStorage.getItem(LOCAL_STORAGE_DOMAIN_CHANGED_CHECKED) === "true";

if (showPopup && !automaticRedirectAccepted) {
if (!automaticRedirectAccepted) {
confirmReadPopup().then(({ value, isConfirmed }) => {
if (isConfirmed) {
if (value) {
localStorage.setItem(
LOCAL_STORAGE_DOMAIN_CHANGED_CHECKED,
"true"
);
}
goToNewDomain();
} else {
setDomainPopupChecked(true);
}
goToNewDomain()
} else {
setDomainPopupChecked(true);
}
});
} else {
goToNewDomain()
});
} else {
goToNewDomain();
}
}
}, []);

Expand Down

0 comments on commit cf6f35c

Please sign in to comment.