diff --git a/client/src/components/forms/PostFormCard.tsx b/client/src/components/forms/PostFormCard.tsx index 9a6c44e..dfda473 100644 --- a/client/src/components/forms/PostFormCard.tsx +++ b/client/src/components/forms/PostFormCard.tsx @@ -122,6 +122,12 @@ const NewNoteCard = ({ const { handleSubmit: originalHandleSubmit, doingWorkProp, hashrate, bestPow, signedPoWEvent } = useSubmitForm(unsigned, difficulty); const handleSubmit = async (event: React.FormEvent) => { + event.preventDefault(); // Prevent default form submission + + if (comment.trim() === "") { + return; // Don't submit if comment is empty or just whitespace + } + // Check if tagType is 'Quote' and update comment if (tagType === 'Quote' && refEvent) { setComment(prevComment => prevComment + '\nnostr:' + nip19.noteEncode(refEvent.id)); diff --git a/client/src/hooks/processedEvents.ts b/client/src/hooks/processedEvents.ts index 340254f..365af53 100644 --- a/client/src/hooks/processedEvents.ts +++ b/client/src/hooks/processedEvents.ts @@ -30,10 +30,22 @@ const useProcessedEvents = (id?: string, filterDifficulty: number = 0) => { }); }); + // Create a Set to keep track of seen pubkeys + const seenPubkeys = new Set(); + return noteEvents .filter(event => { const pow = verifyPow(event); - return (event.kind === 0 || pow >= filterDifficulty) && !(event.kind === 1 && event.tags.some(tag => tag[0] === 'e')); + // Check if the pubkey has been seen before + if (seenPubkeys.has(event.pubkey)) { + return false; + } + // Add the pubkey to the set if it passes the filter + if ((event.kind === 0 || pow >= filterDifficulty) && !(event.kind === 1 && event.tags.some(tag => tag[0] === 'e'))) { + seenPubkeys.add(event.pubkey); + return true; + } + return false; }) .map(event => { const pow = verifyPow(event); // Calculate once and reuse