mirror of
https://github.com/revoltchat/revite.git
synced 2024-11-29 02:10:59 -05:00
fix: delete singleton renderer on channel delete
This commit is contained in:
parent
542c0482c5
commit
0f8be1767d
2 changed files with 19 additions and 0 deletions
|
@ -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) {
|
||||||
|
|
|
@ -222,3 +222,7 @@ export function getRenderer(channel: Channel) {
|
||||||
|
|
||||||
return renderer;
|
return renderer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function deleteRenderer(channel_id: string) {
|
||||||
|
delete renderers[channel_id];
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue