error modal when join url fails
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user