allow pasting an invite URL into the invite code box
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user