Skip to content

Commit

Permalink
Fix crazy relays
Browse files Browse the repository at this point in the history
  • Loading branch information
KoalaSat committed Oct 23, 2024
1 parent a7b307f commit 9bdb9d1
Showing 1 changed file with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ class NotificationsService : Service() {
override fun onDestroy() {
timer.cancel()
stopSubscription()
RelayPool.disconnect()

try {
val connectivityManager =
Expand Down Expand Up @@ -236,7 +237,6 @@ class NotificationsService : Service() {

private fun stopSubscription() {
Client.unsubscribe(clientListener)
RelayPool.disconnect()
}

private fun keepAlive() {
Expand Down Expand Up @@ -286,6 +286,7 @@ class NotificationsService : Service() {
val lastCreatedRelayAt = dao.getLatestRelaysByKind(event.kind)

if (lastCreatedRelayAt == null || lastCreatedRelayAt < event.createdAt) {
stopSubscription()
dao.deleteRelaysByKind(event.kind)
val relays = event.tags
.filter { it.size > 1 && (it[0] == "relay" || it[0] == "r") }
Expand All @@ -295,6 +296,7 @@ class NotificationsService : Service() {
entity
}
connectRelays(relays)
startSubscription()
}
}
}
Expand Down

0 comments on commit 9bdb9d1

Please sign in to comment.