Update Prompt.tsx

This commit is contained in:
Ryan Alexander 2021-08-18 06:28:18 +10:00 committed by GitHub
parent 49d54ee05a
commit dccc0f4eb7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

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) {