fix(invite): fix invite embed logic

This commit is contained in:
Paul Makles 2022-01-10 20:23:06 +00:00
parent 0255c3167a
commit 645221b384

View file

@ -1,5 +1,5 @@
import { Group } from "@styled-icons/boxicons-solid"; import { Group } from "@styled-icons/boxicons-solid";
import { autorun } from "mobx"; import { autorun, reaction } from "mobx";
import { observer } from "mobx-react-lite"; import { observer } from "mobx-react-lite";
import { useHistory } from "react-router-dom"; import { useHistory } from "react-router-dom";
import { RetrievedInvite } from "revolt-api/types/Invites"; import { RetrievedInvite } from "revolt-api/types/Invites";
@ -147,14 +147,16 @@ export function EmbedInvite({ code }: Props) {
history.push( history.push(
`/server/${invite.server_id}/channel/${invite.channel_id}`, `/server/${invite.server_id}/channel/${invite.channel_id}`,
); );
return;
} }
const dispose = autorun(() => { const dispose = reaction(
const server = client.servers.get( () =>
invite.server_id, client.servers.get(
); invite.server_id,
),
defer(() => { (server) => {
if (server) { if (server) {
client.unreads!.markMultipleRead( client.unreads!.markMultipleRead(
server.channel_ids, server.channel_ids,
@ -163,11 +165,11 @@ export function EmbedInvite({ code }: Props) {
history.push( history.push(
`/server/${server._id}/channel/${invite.channel_id}`, `/server/${server._id}/channel/${invite.channel_id}`,
); );
}
});
dispose(); dispose();
}); }
},
);
} }
await client.joinInvite(code); await client.joinInvite(code);