Fix message input

This commit is contained in:
austinkelsay 2024-10-13 15:55:55 -05:00
parent 4d84a15aa8
commit 853d2a9055
2 changed files with 6 additions and 22 deletions

View File

@ -4,35 +4,21 @@ import GenericButton from '@/components/buttons/GenericButton';
import { Panel } from 'primereact/panel';
import { useNDKContext } from "@/context/NDKContext";
import { NDKEvent } from "@nostr-dev-kit/ndk";
import NDK, { NDKNip07Signer } from "@nostr-dev-kit/ndk";
import { useToast } from '@/hooks/useToast';
const MessageInput = ({ onMessageSent }) => {
const MessageInput = () => {
const [message, setMessage] = useState('');
const [collapsed, setCollapsed] = useState(true);
// todo: revert this after testing phase
// const { ndk, addSigner } = useNDKContext();
const ndk = new NDK({
explicitRelayUrls: ["wss://nos.lol/",
"wss://relay.damus.io/",
"wss://relay.snort.social/",
"wss://relay.nostr.band/",
"wss://relay.mutinywallet.com/",
"wss://relay.primal.net/"]
});
const { ndk, addSigner } = useNDKContext();
const { showToast } = useToast();
const handleSubmit = async () => {
if (!message.trim() || !ndk) return;
try {
// if (!ndk.signer) {
// await addSigner();
// }
const nip07signer = new NDKNip07Signer();
await ndk.signer?.user();
ndk.signer = nip07signer;
if (!ndk.signer) {
await addSigner();
}
const event = new NDKEvent(ndk);
event.kind = 1;
event.content = message;
@ -41,7 +27,6 @@ const MessageInput = ({ onMessageSent }) => {
await event.publish();
showToast('success', 'Message Sent', 'Your message has been sent to the PlebDevs community.');
setMessage(''); // Clear the input after successful publish
onMessageSent(); // Call this function to close the accordion
} catch (error) {
console.error("Error publishing message:", error);
showToast('error', 'Error', 'There was an error sending your message. Please try again.');

View File

@ -79,8 +79,7 @@ const Feed = () => {
</div>
<Divider />
<MessageInput
collapsed={false}
// onMessageSent={handleMessageSent}
collapsed={false}
/>
</div>
<div className="min-bottom-bar:hidden">