From dccc0f4eb7d91883bd188a5e2caf5bb592bf145e Mon Sep 17 00:00:00 2001 From: Ryan Alexander <38785445+ryanalexander@users.noreply.github.com> Date: Wed, 18 Aug 2021 06:28:18 +1000 Subject: [PATCH] Update Prompt.tsx --- src/context/intermediate/modals/Prompt.tsx | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/src/context/intermediate/modals/Prompt.tsx b/src/context/intermediate/modals/Prompt.tsx index d58fa53c..f041f010 100644 --- a/src/context/intermediate/modals/Prompt.tsx +++ b/src/context/intermediate/modals/Prompt.tsx @@ -463,9 +463,6 @@ export const SpecialPromptModal = observer((props: SpecialProps) => { } case "create_category": { const [name, setName] = useState(""); - const [cats, setCats] = useState( - 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) {