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:
@@ -1,6 +1,11 @@
|
||||
import { useState } from "react";
|
||||
import type { BUN_SQLITE_COBBLE_BOT_MESSAGES } from "@/db/types/db";
|
||||
import type { BotCreatedData, BotUpdatedData, BotWithLastMessage } from "@/src/types";
|
||||
import type {
|
||||
BotCreatedData,
|
||||
BotRemovedData,
|
||||
BotUpdatedData,
|
||||
BotWithLastMessage,
|
||||
} from "@/src/types";
|
||||
import useServerEvent from "./use-server-event";
|
||||
|
||||
type Params = {
|
||||
@@ -49,6 +54,12 @@ export default function useLiveBots({ bots, open_bot_id, workspace_id = null }:
|
||||
},
|
||||
});
|
||||
|
||||
useServerEvent({
|
||||
event: "server:bot-removed",
|
||||
onData: (data: BotRemovedData) =>
|
||||
setLive((prev) => prev.filter((bot) => bot.id != data.bot_id)),
|
||||
});
|
||||
|
||||
useServerEvent({
|
||||
event: "server:bot-updated",
|
||||
onData: (data: BotUpdatedData) =>
|
||||
|
||||
Reference in New Issue
Block a user