Closed eddiejaoude closed 2 years ago
so we are considering this as a same?
not sure but is soln like?
changing
setEvents([...events,data])
to setEvents([...new Set([...events, data])])
work?
so it will remove those above duplicate entries
This issue is about the map, each event in the list also re-adds the user to the map, but the user is only seen once of the map as they are at the same location
I think we need to have 2 data arrays for the events
Set
as you suggested)okay so,
<Map events={events} />
could we pass <Map events={[...new Set(events)]} />
to remove duplicate entries?
oroh interesting! I like your idea <Map events={[...new Set(events)]} />
, it is much cleaner than the way I was thinking, let's try that 👍
You got it correct, great work @brijeshsoni1300 🔥
The issue still remains
Testing this locally with...
if (
!uniqueUsers.find(
(user) => user.githubUsername._id === data.githubUsername._id
)
) {
setUniqueUsers([...uniqueUsers, data]);
}
what if we have one function which filters our list to have only one entry of object per GitHub URL
function removeDuplicateUsersFromEvents(){
let uniqueEvents = [];
events.forEach(event => {
if(!uniqueEvents.some(uniqueEvent => uniqueEvent.githubUserURL === event.githubUserURL)){
uniqueEvents.push(event);
}
}
);
console.log(events)
console.log("uniqueEvents"+uniqueEvents)
return uniqueEvents;
}
and then passing it to Map
<Map events={removeDuplicateUsersFromEvents()} />
well I checked it locally, it's filtering for your URL there were 23 entries in the events list but one entry after removing dups in uniqueEvents list
Testing this locally with...
if (!uniqueUsers.includes(data.githubUsername._id)) { setUniqueUsers([...uniqueUsers, data]); }
actually in those List of objects we have repeated ids so it will cause dups again
Testing this locally with...
if ( !uniqueUsers.find( (user) => user.githubUsername._id === data.githubUsername._id ) ) { setUniqueUsers([...uniqueUsers, data]); }
okay got it, we are filtering it using Github id so that will be the same for the same user let me try this
Description
Currently the user is added to the map multiple times (only seen once), this will get slow
Maybe check if the user is on the map already, if so do nothing
Screenshots
No response
Additional information
No response