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 () => {
setProcessing(true);
try { try {
setProcessing(true); await client.joinInvite(invite);
if (invite.type === "Server") { history.push(
if (client.servers.get(invite.server_id)) { `/server/${invite.server_id}/channel/${invite.channel_id}`,
history.push( );
`/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("/");
} }
setProcessing(true);
try { try {
setProcessing(true); await client.joinInvite(invite);
if (invite.type === "Server") { history.push(
if ( `/server/${invite.server_id}/channel/${invite.channel_id}`,
client.servers.get(invite.server_id) );
) {
history.push(
`/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);
} }
}}> }}>