diff --git a/src/components/channels/createChannelModal.tsx b/src/components/channels/createChannelModal.tsx index 5c471e21..28f6cc34 100644 --- a/src/components/channels/createChannelModal.tsx +++ b/src/components/channels/createChannelModal.tsx @@ -14,12 +14,14 @@ import { useSetAtom } from 'jotai'; import { getEventHash, signEvent } from 'nostr-tools'; import { useContext, useEffect, useState } from 'react'; import { useForm } from 'react-hook-form'; +import { navigate } from 'vite-plugin-ssr/client/router'; export const CreateChannelModal = () => { const [pool]: any = useContext(RelayContext); const [open, setOpen] = useState(false); const [activeAccount]: any = useLocalStorage('account', {}); const [image, setImage] = useState(DEFAULT_AVATAR); + const [loading, setLoading] = useState(false); const setChannel = useSetAtom(defaultChannelsAtom); @@ -32,6 +34,8 @@ export const CreateChannelModal = () => { } = useForm(); const onSubmit = (data: any) => { + setLoading(true); + const event: any = { content: JSON.stringify(data), created_at: dateToUnix(), @@ -41,7 +45,6 @@ export const CreateChannelModal = () => { }; event.id = getEventHash(event); event.sig = signEvent(event, activeAccount.privkey); - console.log(event); // publish channel pool.publish(event, FULL_RELAYS); @@ -56,10 +59,14 @@ export const CreateChannelModal = () => { created_at: event.created_at, }, ]); - // close modal - setOpen(false); // reset form reset(); + setTimeout(() => { + // close modal + setOpen(false); + // redirect to channel page + navigate(`/channel?id=${event.id}`); + }, 2000); }; useEffect(() => { @@ -174,9 +181,32 @@ export const CreateChannelModal = () => {