fix(invites): use new invite handling

This commit is contained in:
Paul Makles 2022-04-09 19:02:41 +01:00
parent 7b7f3c3af8
commit d129d9816d
2 changed files with 14 additions and 64 deletions

View file

@ -139,42 +139,17 @@ export function EmbedInvite({ code }: Props) {
) : ( ) : (
<Button <Button
onClick={async () => { onClick={async () => {
try {
setProcessing(true); setProcessing(true);
if (invite.type === "Server") { try {
if (client.servers.get(invite.server_id)) { await client.joinInvite(invite);
history.push( history.push(
`/server/${invite.server_id}/channel/${invite.channel_id}`, `/server/${invite.server_id}/channel/${invite.channel_id}`,
); );
return;
}
const dispose = reaction(
() =>
client.servers.get(
invite.server_id,
),
(server) => {
if (server) {
client.unreads!.markMultipleRead(
server.channel_ids,
);
history.push(
`/server/${server._id}/channel/${invite.channel_id}`,
);
dispose();
}
},
);
}
await client.joinInvite(code);
} catch (err) { } catch (err) {
setJoinError(takeError(err)); setJoinError(takeError(err));
} finally {
setProcessing(false); setProcessing(false);
} }
}}> }}>

View file

@ -158,42 +158,17 @@ export default function Invite() {
return history.push("/"); return history.push("/");
} }
try {
setProcessing(true); setProcessing(true);
if (invite.type === "Server") { try {
if ( await client.joinInvite(invite);
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) {
client.unreads!.markMultipleRead(
server.channel_ids,
);
history.push(
`/server/${server._id}/channel/${invite.channel_id}`,
);
}
});
dispose();
});
}
await client.joinInvite(code);
} catch (err) { } catch (err) {
setError(takeError(err)); setError(takeError(err));
} finally {
setProcessing(false); setProcessing(false);
} }
}}> }}>