Only calls invalidate if things change

This commit is contained in:
Vitor Pamplona
2023-05-10 14:02:38 -04:00
parent aa0ace5014
commit a62f2e44d0
2 changed files with 24 additions and 12 deletions
@@ -152,22 +152,30 @@ object NostrSingleEventDataSource : NostrDataSource("SingleEventFeed") {
} }
fun add(eventId: Note) { fun add(eventId: Note) {
eventsToWatch = eventsToWatch.plus(eventId) if (!eventsToWatch.contains(eventId)) {
invalidateFilters() eventsToWatch = eventsToWatch.plus(eventId)
invalidateFilters()
}
} }
fun remove(eventId: Note) { fun remove(eventId: Note) {
eventsToWatch = eventsToWatch.minus(eventId) if (eventsToWatch.contains(eventId)) {
invalidateFilters() eventsToWatch = eventsToWatch.minus(eventId)
invalidateFilters()
}
} }
fun addAddress(aTag: Note) { fun addAddress(aTag: Note) {
addressesToWatch = addressesToWatch.plus(aTag) if (!addressesToWatch.contains(aTag)) {
invalidateFilters() addressesToWatch = addressesToWatch.plus(aTag)
invalidateFilters()
}
} }
fun removeAddress(aTag: Note) { fun removeAddress(aTag: Note) {
addressesToWatch = addressesToWatch.minus(aTag) if (addressesToWatch.contains(aTag)) {
invalidateFilters() addressesToWatch = addressesToWatch.minus(aTag)
invalidateFilters()
}
} }
} }
@@ -64,12 +64,16 @@ object NostrSingleUserDataSource : NostrDataSource("SingleUserFeed") {
} }
fun add(user: User) { fun add(user: User) {
usersToWatch = usersToWatch.plus(user) if (!usersToWatch.contains(user)) {
invalidateFilters() usersToWatch = usersToWatch.plus(user)
invalidateFilters()
}
} }
fun remove(user: User) { fun remove(user: User) {
usersToWatch = usersToWatch.minus(user) if (usersToWatch.contains(user)) {
invalidateFilters() usersToWatch = usersToWatch.minus(user)
invalidateFilters()
}
} }
} }