Skip to content

Commit 4fd4816

Browse files
committed
fix(setup-ui): attempt the success-tab close only once
1 parent 6830d22 commit 4fd4816

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

setup-ui/src/App.tsx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { type ReactNode, type SyntheticEvent, useEffect, useState } from "react";
1+
import { type ReactNode, type SyntheticEvent, useEffect, useRef, useState } from "react";
22
import { ChevronDown, ExternalLink, Loader2 } from "lucide-react";
33

44
import { JellyfinIcon, PlexIcon, TraktIcon } from "@/components/brand-icons";
@@ -488,9 +488,15 @@ function SuccessScreen() {
488488
return () => document.removeEventListener("visibilitychange", onVisibility);
489489
}, []);
490490

491+
const closed = useRef(false);
491492
useEffect(() => {
492493
if (seconds <= 0) {
493-
window.close();
494+
// window.close() is a no-op for tabs the browser opened (not script);
495+
// attempt it once rather than on every later visibility toggle.
496+
if (!closed.current) {
497+
closed.current = true;
498+
window.close();
499+
}
494500
return;
495501
}
496502
if (!visible) return;

0 commit comments

Comments
 (0)