From a782bcb1ca920bcb1286b496c4d43ed1efbe2ab6 Mon Sep 17 00:00:00 2001 From: Adam Lamers Date: Tue, 21 Apr 2026 17:43:10 -0400 Subject: [PATCH] allow pasting an invite URL into the invite code box --- src/chat/components/ServerDiscovery.svelte | 28 ++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/src/chat/components/ServerDiscovery.svelte b/src/chat/components/ServerDiscovery.svelte index 1bdff77..94415fd 100644 --- a/src/chat/components/ServerDiscovery.svelte +++ b/src/chat/components/ServerDiscovery.svelte @@ -19,14 +19,23 @@ joinError = null; }); + $effect(() => { + if (isJoining) { + joinError = null; + } + }); + $effect(() => { if (!isJoining) return; const status = chat.joinServerStatus; + console.log("[Discovery] joinServerStatus updated:", status); + if (status?.status === "error") { joinError = status.error || "Failed to join server"; isJoining = false; // Attempt finished with error } else if (status?.status === "success") { + console.log("[Discovery] Join SUCCESS recorded."); joinError = null; inviteCode = ""; isJoining = false; // Attempt finished with success @@ -48,10 +57,25 @@ ); function handleJoinWithCode() { - if (inviteCode.trim()) { + let finalCode = inviteCode.trim(); + + // Check if the user pasted a full URL + if (finalCode.includes("?invite=") || finalCode.includes("&invite=")) { + try { + const url = new URL(finalCode); + const codeFromUrl = url.searchParams.get("invite"); + if (codeFromUrl) { + finalCode = codeFromUrl; + } + } catch (e) { + // Not a valid URL, treat as raw code + } + } + + if (finalCode) { joinError = null; isJoining = true; - chat.handleJoinServer(undefined, inviteCode.trim()); + chat.handleJoinServer(undefined, finalCode); } }