Skip to content

Commit

Permalink
avoid adding artists that are already playing as part of someone else…
Browse files Browse the repository at this point in the history
…'s show
  • Loading branch information
sam9116 committed Feb 11, 2024
1 parent 128c18b commit 4c638f0
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions src/BaseInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,18 @@ const BaseInput = forwardRef(({ setConcerts, setUserLocation, setMapStyle, start
console.log(`resJson: ${resJson.length}`);
console.log(`add incoming concerts into allconcerts`);
console.log(`total Number Of Concerts Memorized: ${allConcerts.length}`);
setAllConcerts((prev) => prev.concat(resJson));
//avoid adding the same concert.. check the title of the concert
const found = allConcerts.some((concert)=> {

alert(`${incomingArtistName} is already playing as part of ${concert.title}`);

return resJson.includes(concert);});

if(!found)
{
setAllConcerts((prev) => prev.concat(resJson));
}

sortArtist(allConcerts.concat(resJson), userLocation);

} else {
Expand Down Expand Up @@ -135,7 +146,7 @@ var valueDate = new Date(value.date).toDateString();

console.log(`filter the sorted concert by artist name, so we're only left with one concert per artist`);
newConcerts = newConcerts.filter((value, index, self)=>{
return self.findIndex(v => v.artist === value.artist) === index;
return self.findIndex(v => v.artist === value.artist || v.title == value.title) === index;
});

newConcerts = newConcerts.sort((a, b) => { return (new Date(a.date) - new Date(b.date)) });
Expand Down

0 comments on commit 4c638f0

Please sign in to comment.