pull/699/head
Vitor Pamplona 2023-11-24 11:53:51 -05:00
rodzic e7893cacd5
commit df823102da
1 zmienionych plików z 6 dodań i 6 usunięć

Wyświetl plik

@ -149,29 +149,29 @@ abstract class NostrDataSource(val debugName: String) {
// Makes sure to only send an updated filter when it actually changes. // Makes sure to only send an updated filter when it actually changes.
subscriptions.values.forEach { updatedSubscription -> subscriptions.values.forEach { updatedSubscription ->
val updatedSubscriotionNewFilters = updatedSubscription.typedFilters val updatedSubscriptionNewFilters = updatedSubscription.typedFilters
if (updatedSubscription.id in currentFilters.keys) { if (updatedSubscription.id in currentFilters.keys) {
if (updatedSubscriotionNewFilters == null) { if (updatedSubscriptionNewFilters == null) {
// was active and is not active anymore, just close. // was active and is not active anymore, just close.
Client.close(updatedSubscription.id) Client.close(updatedSubscription.id)
} else { } else {
// was active and is still active, check if it has changed. // was active and is still active, check if it has changed.
if (updatedSubscription.toJson() != currentFilters[updatedSubscription.id]) { if (updatedSubscription.toJson() != currentFilters[updatedSubscription.id]) {
Client.close(updatedSubscription.id) Client.close(updatedSubscription.id)
Client.sendFilter(updatedSubscription.id, updatedSubscriotionNewFilters) Client.sendFilter(updatedSubscription.id, updatedSubscriptionNewFilters)
} else { } else {
// hasn't changed, does nothing. // hasn't changed, does nothing.
Client.sendFilterOnlyIfDisconnected(updatedSubscription.id, updatedSubscriotionNewFilters) Client.sendFilterOnlyIfDisconnected(updatedSubscription.id, updatedSubscriptionNewFilters)
} }
} }
} else { } else {
if (updatedSubscriotionNewFilters == null) { if (updatedSubscriptionNewFilters == null) {
// was not active and is still not active, does nothing // was not active and is still not active, does nothing
} else { } else {
// was not active and becomes active, sends the filter. // was not active and becomes active, sends the filter.
if (updatedSubscription.toJson() != currentFilters[updatedSubscription.id]) { if (updatedSubscription.toJson() != currentFilters[updatedSubscription.id]) {
Client.sendFilter(updatedSubscription.id, updatedSubscriotionNewFilters) Client.sendFilter(updatedSubscription.id, updatedSubscriptionNewFilters)
} }
} }
} }