fix connect flow in tray

This commit is contained in:
Eduard Gert
2026-05-22 10:16:13 +02:00
parent 580cfa0dc5
commit 577ce6deb5
5 changed files with 22 additions and 16 deletions

View File

@@ -1,4 +1,4 @@
import { useCallback } from "react";
import { useCallback, useEffect } from "react";
import { useTranslation } from "react-i18next";
import { useSearchParams } from "react-router-dom";
import { Events } from "@wailsio/runtime";
@@ -21,6 +21,15 @@ export default function WaitingForBrowserDialog() {
const uri = params.get("uri") ?? "";
const contentRef = useAutoSizeWindow<HTMLDivElement>(WINDOW_WIDTH);
// 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.
useEffect(() => {
if (!uri) return;
Connection.OpenURL(uri).catch(console.error);
}, [uri]);
const tryAgain = useCallback(() => {
if (!uri) return;
Connection.OpenURL(uri).catch(console.error);