This commit is contained in:
TaiAurori 2021-08-31 20:45:01 +00:00 committed by GitHub
parent 0b0d1186eb
commit f9bb332605
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 34 additions and 34 deletions

View file

@ -158,20 +158,20 @@ const Message = observer(
isInvite = true;
}
})
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");
if (inviteRegex.test(content)) {
let results: string[] = [];
let match: RegExpExecArray | null;
inviteRegex.lastIndex = 0;
while ((match = inviteRegex.exec(content)) !== null) {
if (!results.includes(match[match.length - 1])) {
results.push(match[match.length - 1]);
}
}
return results.map(code => <EmbedInvite code={code} />);
}
}
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");
if (inviteRegex.test(content)) {
let results: string[] = [];
let match: RegExpExecArray | null;
inviteRegex.lastIndex = 0;
while ((match = inviteRegex.exec(content)) !== null) {
if (!results.includes(match[match.length - 1])) {
results.push(match[match.length - 1]);
}
}
return results.map(code => <EmbedInvite code={code} />);
}
}
})()}
{queued?.error && (
<Overline type="error" error={queued.error} />

View file

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