error modal when join url fails

This commit is contained in:
2026-04-21 17:36:47 -04:00
parent 3123bd9d10
commit d10eb7b377
+19 -1
View File
@@ -39,11 +39,29 @@
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");
window.history.replaceState({}, document.title, url.pathname + url.search);
// Setup a one-time listener for the result of this specific link join
const cleanup = $effect.root(() => {
$effect(() => {
const status = chat.joinServerStatus;
if (status?.status === "error") {
chat.confirmModal = {
title: "Failed to Join Server",
message: `The invite link was invalid or has expired. Error: ${status.error || 'Unknown error'}`,
confirmText: "Close",
onConfirm: () => {}
};
cleanup();
} else if (status?.status === "success") {
cleanup();
}
});
});
}
}, 500);
}