mirror of
https://github.com/revoltchat/revite.git
synced 2024-11-09 16:53:36 -05:00
fix(invites): use new invite handling
This commit is contained in:
parent
7b7f3c3af8
commit
d129d9816d
2 changed files with 14 additions and 64 deletions
|
@ -139,42 +139,17 @@ export function EmbedInvite({ code }: Props) {
|
|||
) : (
|
||||
<Button
|
||||
onClick={async () => {
|
||||
setProcessing(true);
|
||||
|
||||
try {
|
||||
setProcessing(true);
|
||||
await client.joinInvite(invite);
|
||||
|
||||
if (invite.type === "Server") {
|
||||
if (client.servers.get(invite.server_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);
|
||||
history.push(
|
||||
`/server/${invite.server_id}/channel/${invite.channel_id}`,
|
||||
);
|
||||
} catch (err) {
|
||||
setJoinError(takeError(err));
|
||||
} finally {
|
||||
setProcessing(false);
|
||||
}
|
||||
}}>
|
||||
|
|
|
@ -158,42 +158,17 @@ export default function Invite() {
|
|||
return history.push("/");
|
||||
}
|
||||
|
||||
setProcessing(true);
|
||||
|
||||
try {
|
||||
setProcessing(true);
|
||||
await client.joinInvite(invite);
|
||||
|
||||
if (invite.type === "Server") {
|
||||
if (
|
||||
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);
|
||||
history.push(
|
||||
`/server/${invite.server_id}/channel/${invite.channel_id}`,
|
||||
);
|
||||
} catch (err) {
|
||||
setError(takeError(err));
|
||||
} finally {
|
||||
setProcessing(false);
|
||||
}
|
||||
}}>
|
||||
|
|
Loading…
Reference in a new issue