error messaging for server joins

This commit is contained in:
2026-04-21 17:40:35 -04:00
parent d10eb7b377
commit d53254a615
2 changed files with 13 additions and 1 deletions
+1 -1
View File
@@ -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());
}
}