Update Prompt.tsx

This commit is contained in:
Ryan Alexander
2021-08-18 06:28:18 +10:00
committed by GitHub
parent 5b64ee5b0b
commit a5842fe0d0

View File

@@ -463,9 +463,6 @@ export const SpecialPromptModal = observer((props: SpecialProps) => {
} }
case "create_category": { case "create_category": {
const [name, setName] = useState(""); const [name, setName] = useState("");
const [cats, setCats] = useState<Category[]>(
props.target.categories ?? [],
);
const history = useHistory(); const history = useHistory();
return ( return (
@@ -482,12 +479,12 @@ export const SpecialPromptModal = observer((props: SpecialProps) => {
onClick: async () => { onClick: async () => {
setProcessing(true); setProcessing(true);
try { try {
cats.push({ props.target.edit({
id: ulid(), categories: [
title: name, ...props.target.categories ?? [],
channels: [], { id: ulid(), title: name, channels: [] }
]
}); });
props.target.edit({ categories: cats });
onClose(); onClose();
setProcessing(false); setProcessing(false);
} catch (err) { } catch (err) {