mirror of
https://github.com/AustinKelsay/plebdevs.git
synced 2025-06-05 00:32:03 +00:00
remove duplicate deduping
This commit is contained in:
parent
fac14d5b77
commit
14d63d7240
@ -107,15 +107,11 @@ const useLessons = (ndk, fetchAuthor, lessonIds, pubkey) => {
|
|||||||
const events = await ndk.fetchEvents(filter);
|
const events = await ndk.fetchEvents(filter);
|
||||||
const newLessons = [];
|
const newLessons = [];
|
||||||
|
|
||||||
// Process events without duplicating
|
// Process events (no need to check for duplicates here)
|
||||||
for (const event of events) {
|
for (const event of events) {
|
||||||
const author = await fetchAuthor(event.pubkey);
|
const author = await fetchAuthor(event.pubkey);
|
||||||
const parsedLesson = { ...parseEvent(event), author };
|
const parsedLesson = { ...parseEvent(event), author };
|
||||||
|
newLessons.push(parsedLesson);
|
||||||
// Only add if not already in newLessons array
|
|
||||||
if (!newLessons.some(lesson => lesson.id === parsedLesson.id)) {
|
|
||||||
newLessons.push(parsedLesson);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
setLessons(newLessons);
|
setLessons(newLessons);
|
||||||
@ -128,6 +124,7 @@ const useLessons = (ndk, fetchAuthor, lessonIds, pubkey) => {
|
|||||||
}
|
}
|
||||||
}, [lessonIds, ndk, fetchAuthor, pubkey]);
|
}, [lessonIds, ndk, fetchAuthor, pubkey]);
|
||||||
|
|
||||||
|
// Keep this deduplication logic using Map
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const newUniqueLessons = Array.from(
|
const newUniqueLessons = Array.from(
|
||||||
new Map(lessons.map(lesson => [lesson.id, lesson])).values()
|
new Map(lessons.map(lesson => [lesson.id, lesson])).values()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user