add visible joining indicator

This commit is contained in:
TaiAurori 2021-08-31 21:37:42 +00:00 committed by GitHub
parent a10e5100d3
commit 2f950aab53
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -106,49 +106,56 @@ export default function EmbedInvite(props: Props) {
{invite.member_count} members {invite.member_count} members
</EmbedInviteMemberCount> </EmbedInviteMemberCount>
</EmbedInviteDetails> </EmbedInviteDetails>
<Button onClick={async () => { {processing ? (
try { <div>
setProcessing(true); <Preloader type="ring" />
</div>
) : (
<Button onClick={async () => {
try {
setProcessing(true);
if (invite.type === "Server") { if (invite.type === "Server") {
if ( if (
client.servers.get(invite.server_id) client.servers.get(invite.server_id)
) { ) {
history.push( history.push(
`/server/${invite.server_id}/channel/${invite.channel_id}`, `/server/${invite.server_id}/channel/${invite.channel_id}`,
); );
}
const dispose = autorun(() => {
const server = client.servers.get(
invite.server_id,
);
defer(() => {
if (server) {
dispatch({
type: "UNREADS_MARK_MULTIPLE_READ",
channels:
server.channel_ids,
});
history.push(
`/server/${server._id}/channel/${invite.channel_id}`,
);
}
});
dispose();
});
} }
const dispose = autorun(() => { await client.joinInvite(code);
const server = client.servers.get( setProcessing(false);
invite.server_id, } catch (err) {
); setError(takeError(err));
setProcessing(false);
defer(() => {
if (server) {
dispatch({
type: "UNREADS_MARK_MULTIPLE_READ",
channels:
server.channel_ids,
});
history.push(
`/server/${server._id}/channel/${invite.channel_id}`,
);
}
});
dispose();
});
} }
}}>
await client.joinInvite(code); {client.servers.get(invite.server_id) ? "Joined" : "Join"}
} catch (err) { </Button>
setError(takeError(err)); )}
setProcessing(false);
}
}}>
{client.servers.get(invite.server_id) ? "Joined" : "Join"}
</Button>
</EmbedInviteBase> </EmbedInviteBase>
} }