update peers filter, fix duplicate url open in dev

This commit is contained in:
Eduard Gert
2026-05-26 09:35:03 +02:00
parent d624c2db74
commit f8c107b087
2 changed files with 8 additions and 6 deletions

View File

@@ -1,4 +1,4 @@
import { useCallback, useEffect } from "react";
import { useCallback, useEffect, useRef } from "react";
import { useTranslation } from "react-i18next";
import { useSearchParams } from "react-router-dom";
import { Dialogs, Events } from "@wailsio/runtime";
@@ -21,6 +21,7 @@ export default function WaitingForBrowserDialog() {
const [params] = useSearchParams();
const uri = params.get("uri") ?? "";
const contentRef = useAutoSizeWindow<HTMLDivElement>(WINDOW_WIDTH);
const openedRef = useRef(false);
const reportOpenFailure = useCallback(
(e: unknown) => {
@@ -35,9 +36,12 @@ export default function WaitingForBrowserDialog() {
// Open the system browser only after the dialog has mounted (which
// means useAutoSizeWindow has called Window.Show). startLogin used to
// fire OpenURL itself but the browser typically beat React's mount
// and landed on top of the still-hidden NetBird popup.
// and landed on top of the still-hidden NetBird popup. The ref guard
// keeps StrictMode's intentional double-invoke in dev (and any future
// remount) from launching two browser tabs.
useEffect(() => {
if (!uri) return;
if (!uri || openedRef.current) return;
openedRef.current = true;
Connection.OpenURL(uri).catch(reportOpenFailure);
}, [uri, reportOpenFailure]);

View File

@@ -28,9 +28,7 @@ export const PeerFilters = ({ value, onChange, counts }: Props) => {
{filters.map((f) => (
<SwitchItem key={f.value} value={f.value} className={"flex-1"}>
{f.label}
<span className={"font-normal text-nb-gray-200"}>
{counts[f.value]}
</span>
<span className={"tabular-nums"}>({counts[f.value]})</span>
</SwitchItem>
))}
</SwitchItemGroup>