mirror of
https://github.com/AustinKelsay/plebdevs.git
synced 2025-06-22 15:35:05 +00:00
Fix message input
This commit is contained in:
parent
4d84a15aa8
commit
853d2a9055
@ -4,35 +4,21 @@ import GenericButton from '@/components/buttons/GenericButton';
|
|||||||
import { Panel } from 'primereact/panel';
|
import { Panel } from 'primereact/panel';
|
||||||
import { useNDKContext } from "@/context/NDKContext";
|
import { useNDKContext } from "@/context/NDKContext";
|
||||||
import { NDKEvent } from "@nostr-dev-kit/ndk";
|
import { NDKEvent } from "@nostr-dev-kit/ndk";
|
||||||
import NDK, { NDKNip07Signer } from "@nostr-dev-kit/ndk";
|
|
||||||
import { useToast } from '@/hooks/useToast';
|
import { useToast } from '@/hooks/useToast';
|
||||||
|
|
||||||
const MessageInput = ({ onMessageSent }) => {
|
const MessageInput = () => {
|
||||||
const [message, setMessage] = useState('');
|
const [message, setMessage] = useState('');
|
||||||
const [collapsed, setCollapsed] = useState(true);
|
const [collapsed, setCollapsed] = useState(true);
|
||||||
// todo: revert this after testing phase
|
const { ndk, addSigner } = useNDKContext();
|
||||||
// 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 { showToast } = useToast();
|
const { showToast } = useToast();
|
||||||
|
|
||||||
const handleSubmit = async () => {
|
const handleSubmit = async () => {
|
||||||
if (!message.trim() || !ndk) return;
|
if (!message.trim() || !ndk) return;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// if (!ndk.signer) {
|
if (!ndk.signer) {
|
||||||
// await addSigner();
|
await addSigner();
|
||||||
// }
|
}
|
||||||
|
|
||||||
const nip07signer = new NDKNip07Signer();
|
|
||||||
await ndk.signer?.user();
|
|
||||||
ndk.signer = nip07signer;
|
|
||||||
const event = new NDKEvent(ndk);
|
const event = new NDKEvent(ndk);
|
||||||
event.kind = 1;
|
event.kind = 1;
|
||||||
event.content = message;
|
event.content = message;
|
||||||
@ -41,7 +27,6 @@ const MessageInput = ({ onMessageSent }) => {
|
|||||||
await event.publish();
|
await event.publish();
|
||||||
showToast('success', 'Message Sent', 'Your message has been sent to the PlebDevs community.');
|
showToast('success', 'Message Sent', 'Your message has been sent to the PlebDevs community.');
|
||||||
setMessage(''); // Clear the input after successful publish
|
setMessage(''); // Clear the input after successful publish
|
||||||
onMessageSent(); // Call this function to close the accordion
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Error publishing message:", error);
|
console.error("Error publishing message:", error);
|
||||||
showToast('error', 'Error', 'There was an error sending your message. Please try again.');
|
showToast('error', 'Error', 'There was an error sending your message. Please try again.');
|
||||||
|
@ -79,8 +79,7 @@ const Feed = () => {
|
|||||||
</div>
|
</div>
|
||||||
<Divider />
|
<Divider />
|
||||||
<MessageInput
|
<MessageInput
|
||||||
collapsed={false}
|
collapsed={false}
|
||||||
// onMessageSent={handleMessageSent}
|
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div className="min-bottom-bar:hidden">
|
<div className="min-bottom-bar:hidden">
|
||||||
|
Loading…
x
Reference in New Issue
Block a user