error messaging for server joins
This commit is contained in:
@@ -39,7 +39,7 @@
|
||||
if (chat.isReady) {
|
||||
clearInterval(checkReady);
|
||||
chat.handleJoinServer(undefined, inviteCode);
|
||||
|
||||
|
||||
// Clear URL parameter without reloading
|
||||
const url = new URL(window.location.href);
|
||||
url.searchParams.delete("invite");
|
||||
|
||||
@@ -11,14 +11,25 @@
|
||||
let searchTerm = $state("");
|
||||
let inviteCode = $state("");
|
||||
let joinError = $state<string | null>(null);
|
||||
let isJoining = $state(false);
|
||||
|
||||
$effect(() => {
|
||||
// Clear error when user changes the invite code
|
||||
const _ = inviteCode;
|
||||
joinError = null;
|
||||
});
|
||||
|
||||
$effect(() => {
|
||||
if (!isJoining) return;
|
||||
|
||||
const status = chat.joinServerStatus;
|
||||
if (status?.status === "error") {
|
||||
joinError = status.error || "Failed to join server";
|
||||
isJoining = false; // Attempt finished with error
|
||||
} else if (status?.status === "success") {
|
||||
joinError = null;
|
||||
inviteCode = "";
|
||||
isJoining = false; // Attempt finished with success
|
||||
|
||||
// Navigate to the joined server
|
||||
if (status.serverId) {
|
||||
@@ -39,6 +50,7 @@
|
||||
function handleJoinWithCode() {
|
||||
if (inviteCode.trim()) {
|
||||
joinError = null;
|
||||
isJoining = true;
|
||||
chat.handleJoinServer(undefined, inviteCode.trim());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user