import { createSignal, Show, type JSX, Component } from 'solid-js'; import MagnifyingGlass from 'heroicons/24/solid/magnifying-glass.svg'; import PencilSquare from 'heroicons/24/solid/pencil-square.svg'; import Cog6Tooth from 'heroicons/24/outline/cog-6-tooth.svg'; import NotePostForm from '@/components/NotePostForm'; import Config from '@/components/Config'; import useConfig from '@/nostr/useConfig'; import useCommands from '@/nostr/useCommands'; import usePubkey from '@/nostr/usePubkey'; import { useHandleCommand } from '@/hooks/useCommandBus'; const SideBar: Component = () => { let formTextAreaRef: HTMLTextAreaElement | undefined; const { config } = useConfig(); const getPubkey = usePubkey(); const commands = useCommands(); const [formOpened, setFormOpened] = createSignal(false); const [configOpened, setConfigOpened] = createSignal(false); const openForm = () => { setFormOpened(true); setTimeout(() => { formTextAreaRef?.focus?.(); }, 100); }; const closeForm = () => { setFormOpened(false); formTextAreaRef?.blur?.(); }; const handlePost = ({ content }: { content: string }) => { const pubkey = getPubkey(); if (pubkey == null) { console.error('pubkey is not available'); return; } commands .publishTextNote({ relayUrls: config().relayUrls, pubkey, content, }) .then(() => { console.log('ok'); }) .catch((err) => { console.error('error', err); }); }; useHandleCommand(() => ({ commandType: 'openPostForm', handler: (cmd) => { openForm(); }, })); return (
{/* */} {/*
column 1
*/} {/*
column 2
*/}
setConfigOpened(false)} />
); }; export default SideBar;