fix: delete singleton renderer on channel delete

This commit is contained in:
Paul Makles 2022-03-04 16:45:57 +00:00
parent 542c0482c5
commit 0f8be1767d
2 changed files with 19 additions and 0 deletions

View file

@ -1,7 +1,10 @@
import { Client } from "revolt.js/dist"; import { Client } from "revolt.js/dist";
import { Server } from "revolt.js/dist/maps/Servers";
import { StateUpdater } from "preact/hooks"; import { StateUpdater } from "preact/hooks";
import { deleteRenderer } from "../../lib/renderer/Singleton";
import Auth from "../../mobx/stores/Auth"; import Auth from "../../mobx/stores/Auth";
import { resetMemberSidebarFetched } from "../../components/navigation/right/MemberSidebar"; import { resetMemberSidebarFetched } from "../../components/navigation/right/MemberSidebar";
@ -28,6 +31,18 @@ export function registerEvents(
auth.logout(); auth.logout();
setStatus(ClientStatus.READY); setStatus(ClientStatus.READY);
}, },
"channel/delete": (channel_id: string) => {
deleteRenderer(channel_id);
},
"server/delete": (_, server: Server) => {
if (server) {
for (const channel_id of server.channel_ids) {
deleteRenderer(channel_id);
}
}
},
}; };
if (import.meta.env.DEV) { if (import.meta.env.DEV) {

View file

@ -222,3 +222,7 @@ export function getRenderer(channel: Channel) {
return renderer; return renderer;
} }
export function deleteRenderer(channel_id: string) {
delete renderers[channel_id];
}