From 9bdb9d15bd8704865a3ab0ea2d610563f79f4684 Mon Sep 17 00:00:00 2001 From: koalasat Date: Wed, 23 Oct 2024 18:15:38 +0200 Subject: [PATCH] Fix crazy relays --- .../java/com/koalasat/pokey/service/NotificationsService.kt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/com/koalasat/pokey/service/NotificationsService.kt b/app/src/main/java/com/koalasat/pokey/service/NotificationsService.kt index 17704ca..254214b 100644 --- a/app/src/main/java/com/koalasat/pokey/service/NotificationsService.kt +++ b/app/src/main/java/com/koalasat/pokey/service/NotificationsService.kt @@ -176,6 +176,7 @@ class NotificationsService : Service() { override fun onDestroy() { timer.cancel() stopSubscription() + RelayPool.disconnect() try { val connectivityManager = @@ -236,7 +237,6 @@ class NotificationsService : Service() { private fun stopSubscription() { Client.unsubscribe(clientListener) - RelayPool.disconnect() } private fun keepAlive() { @@ -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") } @@ -295,6 +296,7 @@ class NotificationsService : Service() { entity } connectRelays(relays) + startSubscription() } } }