Refactor invite state handling and add group invite message

This commit is contained in:
beak2825
2025-12-26 16:38:25 -05:00
committed by GitHub
parent 41f47a1a3f
commit ce56bbebbf

View File

@@ -82,7 +82,7 @@ export function EmbedInvite({ code }: Props) {
const [error, setError] = useState<string | undefined>(undefined); const [error, setError] = useState<string | undefined>(undefined);
const [joinError, setJoinError] = useState<string | undefined>(undefined); const [joinError, setJoinError] = useState<string | undefined>(undefined);
const [invite, setInvite] = useState< const [invite, setInvite] = useState<
(API.InviteResponse & { type: "Server" }) | undefined API.InviteResponse | undefined
>(undefined); >(undefined);
useEffect(() => { useEffect(() => {
@@ -93,7 +93,7 @@ export function EmbedInvite({ code }: Props) {
client client
.fetchInvite(code) .fetchInvite(code)
.then((data) => .then((data) =>
setInvite(data as API.InviteResponse & { type: "Server" }), setInvite(data as API.InviteResponse),
) )
.catch((err) => setError(takeError(err))); .catch((err) => setError(takeError(err)));
} }
@@ -114,6 +114,17 @@ export function EmbedInvite({ code }: Props) {
); );
} }
if (invite.type === "Group") {
return (
<EmbedInviteBase>
<ServerIcon size={55} />
<EmbedInviteDetails>
<EmbedInviteName>Group Invites are not supported at this time.</EmbedInviteName>
</EmbedInviteDetails>
</EmbedInviteBase>
);
}
return ( return (
<> <>
<EmbedInviteBase> <EmbedInviteBase>