Take a deleted bot out of the rail at once
Deleting a bot only changed the page after a reload. The delete route now reads who could see the bot before removing it, since its assignments and workspace places go with it, then pushes server:bot-removed (BotRemovedData) to them. useLiveBots drops the row, so every tab and every workspace the bot was in updates together.
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
import { sendToUser } from "@/src/websocket/(functions)/send-to-user";
|
||||
|
||||
type Params = {
|
||||
bot_id: number | string;
|
||||
/**
|
||||
* Everyone who saw the bot, read before its row was deleted: afterwards
|
||||
* its assignments and workspace places are gone with it, so its
|
||||
* audience can't be worked out any more.
|
||||
*/
|
||||
user_ids: number[];
|
||||
};
|
||||
|
||||
/**
|
||||
* Pushes `server:bot-removed` to everyone who could see a bot that was
|
||||
* deleted, so its rail row goes at once and nothing opens a dead
|
||||
* conversation.
|
||||
*/
|
||||
export default function pushBotRemoved({ bot_id, user_ids }: Params) {
|
||||
for (const user_id of user_ids) {
|
||||
sendToUser({
|
||||
user_id,
|
||||
data: {
|
||||
event: "server:bot-removed",
|
||||
data: { bot_id: Number(bot_id) },
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user