mirror of
https://github.com/smolgrrr/TAO.git
synced 2024-09-20 01:11:25 +00:00
rm duplicate events by the same pubkey
This commit is contained in:
parent
49d5c3d400
commit
2cf24b1f72
@ -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));
|
||||
|
@ -30,10 +30,22 @@ const useProcessedEvents = (id?: string, filterDifficulty: number = 0) => {
|
||||
});
|
||||
});
|
||||
|
||||
// Create a Set to keep track of seen pubkeys
|
||||
const seenPubkeys = new Set<string>();
|
||||
|
||||
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
|
||||
|
Loading…
Reference in New Issue
Block a user