import { Dropdown, type DropdownItem, IconButton } from "@yaakapp-internal/ui"; import { useAtomValue } from "jotai"; import { useRpcMutation } from "../hooks/useRpcMutation"; import { flowTotalAtom } from "../lib/store"; /** Deletes every flow, once confirmed in its menu, which its hotkey opens too */ export function ClearFlowsButton() { const total = useAtomValue(flowTotalAtom); const clear = useRpcMutation("clear_flows"); const items: DropdownItem[] = [ { type: "content", label: (
{total === 1 ? "Clear 1 flow?" : `Clear all ${total} flows?`}
{clear.error != null ? ( {clear.error.message} ) : ( "They are deleted from disk with their bodies, for good." )}
), }, { type: "separator" }, { label: "Clear", icon: "trash", color: "danger", onSelect: () => clear.mutate({}), }, ]; return ( ); }