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