@ -257,6 +257,8 @@ document.body.addEventListener('click', (e) => {
const textNoteList = [ ] ; // could use indexDB
const textNoteList = [ ] ; // could use indexDB
const eventRelayMap = { } ; // eventId: [relay1, relay2]
const eventRelayMap = { } ; // eventId: [relay1, relay2]
const replyList = [ ] ;
const reactionMap = { } ;
const hasEventTag = tag => tag [ 0 ] === 'e' ;
const hasEventTag = tag => tag [ 0 ] === 'e' ;
const dropDuplicateToggle = document . querySelector ( '#duplicates' ) ;
const dropDuplicateToggle = document . querySelector ( '#duplicates' ) ;
@ -269,9 +271,12 @@ dropDuplicateToggle.checked = dropDuplicate;
function isValidNote ( evt ) {
function isValidNote ( evt ) {
if ( dropDuplicate ) {
if ( dropDuplicate ) {
const similarEvents = textNoteList . filter ( ( { content } ) => content === evt . content ) ;
const similarEvents = [
... textNoteList . filter ( ( { content } ) => content === evt . content ) ,
... replyList . filter ( ( { content } ) => content === evt . content ) ,
] . filter ( ( { created _at } ) => ( ( created _at + 3600 ) > evt . created _at ) ) ;
if ( similarEvents ? . length >= 5 ) {
if ( similarEvents ? . length >= 5 ) {
console . info ( ` DROP event ${ evt . id } already got ${ similarEvents . length } ` , similarEvents ) ;
console . info ( ` DROP event with content: "${ evt . content . trim ( ) } " already got ${ similarEvents . length } similar events withing the last hour `, similarEvents , ` \n dropped event id: ${ evt . id } ` ) ;
return false ;
return false ;
}
}
}
}
@ -295,9 +300,6 @@ function handleTextNote(evt, relay) {
}
}
}
}
const replyList = [ ] ;
const reactionMap = { } ;
const getReactionList = ( id ) => {
const getReactionList = ( id ) => {
return reactionMap [ id ] ? . map ( ( { content } ) => content ) || [ ] ;
return reactionMap [ id ] ? . map ( ( { content } ) => content ) || [ ] ;
} ;
} ;
@ -379,6 +381,7 @@ setInterval(() => {
} , 10000 ) ;
} , 10000 ) ;
const getNoxyUrl = ( type , url , id , relay ) => {
const getNoxyUrl = ( type , url , id , relay ) => {
return false ;
if ( ! isHttpUrl ( url ) ) {
if ( ! isHttpUrl ( url ) ) {
return false ;
return false ;
}
}
@ -393,6 +396,9 @@ const fetchQue = [];
let fetchPending ;
let fetchPending ;
const fetchNext = ( href , id , relay ) => {
const fetchNext = ( href , id , relay ) => {
const noxy = getNoxyUrl ( 'meta' , href , id , relay ) ;
const noxy = getNoxyUrl ( 'meta' , href , id , relay ) ;
if ( ! noxy ) {
return ;
}
const previewId = noxy . searchParams . toString ( ) ;
const previewId = noxy . searchParams . toString ( ) ;
if ( fetchPending ) {
if ( fetchPending ) {
fetchQue . push ( { href , id , relay } ) ;
fetchQue . push ( { href , id , relay } ) ;