allow pasting an invite URL into the invite code box
This commit is contained in:
@@ -19,14 +19,23 @@
|
|||||||
joinError = null;
|
joinError = null;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$effect(() => {
|
||||||
|
if (isJoining) {
|
||||||
|
joinError = null;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
$effect(() => {
|
$effect(() => {
|
||||||
if (!isJoining) return;
|
if (!isJoining) return;
|
||||||
|
|
||||||
const status = chat.joinServerStatus;
|
const status = chat.joinServerStatus;
|
||||||
|
console.log("[Discovery] joinServerStatus updated:", status);
|
||||||
|
|
||||||
if (status?.status === "error") {
|
if (status?.status === "error") {
|
||||||
joinError = status.error || "Failed to join server";
|
joinError = status.error || "Failed to join server";
|
||||||
isJoining = false; // Attempt finished with error
|
isJoining = false; // Attempt finished with error
|
||||||
} else if (status?.status === "success") {
|
} else if (status?.status === "success") {
|
||||||
|
console.log("[Discovery] Join SUCCESS recorded.");
|
||||||
joinError = null;
|
joinError = null;
|
||||||
inviteCode = "";
|
inviteCode = "";
|
||||||
isJoining = false; // Attempt finished with success
|
isJoining = false; // Attempt finished with success
|
||||||
@@ -48,10 +57,25 @@
|
|||||||
);
|
);
|
||||||
|
|
||||||
function handleJoinWithCode() {
|
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;
|
joinError = null;
|
||||||
isJoining = true;
|
isJoining = true;
|
||||||
chat.handleJoinServer(undefined, inviteCode.trim());
|
chat.handleJoinServer(undefined, finalCode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
Reference in New Issue
Block a user