This commit is contained in:
TaiAurori 2021-08-31 20:45:01 +00:00 committed by GitHub
parent 0b0d1186eb
commit f9bb332605
WARNING! Although there is a key with this ID in the database it does not verify this commit! This commit is SUSPICIOUS.
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 34 additions and 34 deletions

View file

@ -158,20 +158,20 @@ const Message = observer(
isInvite = true; isInvite = true;
} }
}) })
if (isInvite) { if (isInvite) {
const inviteRegex = new RegExp("(?:" + INVITE_PATHS.map((path, index) => path.split(".").join("\\.") + (index !== INVITE_PATHS.length - 1 ? "|" : "")).join("") + ")/([A-Za-z0-9]*)", "g"); const inviteRegex = new RegExp("(?:" + INVITE_PATHS.map((path, index) => path.split(".").join("\\.") + (index !== INVITE_PATHS.length - 1 ? "|" : "")).join("") + ")/([A-Za-z0-9]*)", "g");
if (inviteRegex.test(content)) { if (inviteRegex.test(content)) {
let results: string[] = []; let results: string[] = [];
let match: RegExpExecArray | null; let match: RegExpExecArray | null;
inviteRegex.lastIndex = 0; inviteRegex.lastIndex = 0;
while ((match = inviteRegex.exec(content)) !== null) { while ((match = inviteRegex.exec(content)) !== null) {
if (!results.includes(match[match.length - 1])) { if (!results.includes(match[match.length - 1])) {
results.push(match[match.length - 1]); results.push(match[match.length - 1]);
} }
} }
return results.map(code => <EmbedInvite code={code} />); return results.map(code => <EmbedInvite code={code} />);
} }
} }
})()} })()}
{queued?.error && ( {queued?.error && (
<Overline type="error" error={queued.error} /> <Overline type="error" error={queued.error} />

View file

@ -74,29 +74,29 @@ export default function EmbedInvite(props: Props) {
}, [client, code, invite, status]); }, [client, code, invite, status]);
if (typeof invite === "undefined") { if (typeof invite === "undefined") {
return <EmbedInviteBase> return <EmbedInviteBase>
{error ? ( {error ? (
<Overline type="error" error={error} /> <Overline type="error" error={error} />
) : ( ) : (
<Preloader type="ring" /> <Preloader type="ring" />
)} )}
</EmbedInviteBase> </EmbedInviteBase>
} }
return <EmbedInviteBase> return <EmbedInviteBase>
<ServerIcon <ServerIcon
attachment={invite.server_icon} attachment={invite.server_icon}
server_name={invite.server_name} server_name={invite.server_name}
size={55} size={55}
/> />
<EmbedInviteDetails> <EmbedInviteDetails>
<EmbedInviteName> <EmbedInviteName>
{invite.server_name} {invite.server_name}
</EmbedInviteName> </EmbedInviteName>
<EmbedInviteMemberCount> <EmbedInviteMemberCount>
{invite.member_count} members {invite.member_count} members
</EmbedInviteMemberCount> </EmbedInviteMemberCount>
</EmbedInviteDetails> </EmbedInviteDetails>
<Button onClick={async () => { <Button onClick={async () => {
try { try {
setProcessing(true); setProcessing(true);
@ -139,7 +139,7 @@ export default function EmbedInvite(props: Props) {
setProcessing(false); setProcessing(false);
} }
}}> }}>
{client.servers.get(invite.server_id) ? "Joined" : "Join"} {client.servers.get(invite.server_id) ? "Joined" : "Join"}
</Button> </Button>
</EmbedInviteBase> </EmbedInviteBase>
} }