From da8351b7d5fb1865050dfbdf62d4dcb814ca2320 Mon Sep 17 00:00:00 2001 From: Claude Date: Mon, 11 May 2026 10:34:32 +0000 Subject: [PATCH] Drop unused dispose()/clearForAccount helpers MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit NotificationSubscription/ProfileSubscription/ZapstoreUpdater.dispose() and LocalKeyAccountIndex.clearForAccount() had no callers — these singletons are constructed exactly once per process and their state is rebuilt by NotificationSubscription.updateFilter, so the cleanup paths are dead code. https://claude.ai/code/session_01GiLqaAahYySDdmBa4VksWR --- .../service/LocalKeyAccountIndex.kt | 4 ---- .../service/NotificationSubscription.kt | 18 ++---------------- .../nostrsigner/service/ProfileSubscription.kt | 16 ++-------------- .../nostrsigner/service/ZapstoreUpdater.kt | 15 +-------------- 4 files changed, 5 insertions(+), 48 deletions(-) diff --git a/app/src/main/java/com/greenart7c3/nostrsigner/service/LocalKeyAccountIndex.kt b/app/src/main/java/com/greenart7c3/nostrsigner/service/LocalKeyAccountIndex.kt index 72065c4b..09dab5d3 100644 --- a/app/src/main/java/com/greenart7c3/nostrsigner/service/LocalKeyAccountIndex.kt +++ b/app/src/main/java/com/greenart7c3/nostrsigner/service/LocalKeyAccountIndex.kt @@ -19,8 +19,4 @@ object LocalKeyAccountIndex { byLocalPubKey.keys.retainAll(entries.keys) byLocalPubKey.putAll(entries) } - - fun clearForAccount(npub: String) { - byLocalPubKey.entries.removeAll { it.value.npub == npub } - } } diff --git a/app/src/main/java/com/greenart7c3/nostrsigner/service/NotificationSubscription.kt b/app/src/main/java/com/greenart7c3/nostrsigner/service/NotificationSubscription.kt index a64d4125..6d57d7b3 100644 --- a/app/src/main/java/com/greenart7c3/nostrsigner/service/NotificationSubscription.kt +++ b/app/src/main/java/com/greenart7c3/nostrsigner/service/NotificationSubscription.kt @@ -44,23 +44,9 @@ class NotificationSubscription( private val eventNotificationConsumer = EventNotificationConsumer(appContext) private val subIds = mutableMapOf() - @Volatile - private var registered = false - init { - // listens until the app crashes — guard so re-init in tests - // doesn't double-register the listener. - if (!registered) { - client.addConnectionListener(this) - registered = true - } - } - - fun dispose() { - if (registered) { - client.removeConnectionListener(this) - registered = false - } + // listens until the app crashes. + client.addConnectionListener(this) } override fun onIncomingMessage(relay: IRelayClient, msgStr: String, msg: Message) { diff --git a/app/src/main/java/com/greenart7c3/nostrsigner/service/ProfileSubscription.kt b/app/src/main/java/com/greenart7c3/nostrsigner/service/ProfileSubscription.kt index 133898de..1e891bf6 100644 --- a/app/src/main/java/com/greenart7c3/nostrsigner/service/ProfileSubscription.kt +++ b/app/src/main/java/com/greenart7c3/nostrsigner/service/ProfileSubscription.kt @@ -54,21 +54,9 @@ class ProfileSubscription( private val relaysPerSubId = mutableMapOf>() private val timeoutJobs = mutableMapOf() - @Volatile - private var registered = false - init { - if (!registered) { - client.addConnectionListener(this) - registered = true - } - } - - fun dispose() { - if (registered) { - client.removeConnectionListener(this) - registered = false - } + // listens until the app crashes. + client.addConnectionListener(this) } override fun onIncomingMessage(relay: IRelayClient, msgStr: String, msg: Message) { diff --git a/app/src/main/java/com/greenart7c3/nostrsigner/service/ZapstoreUpdater.kt b/app/src/main/java/com/greenart7c3/nostrsigner/service/ZapstoreUpdater.kt index 12b079c7..979fb01f 100644 --- a/app/src/main/java/com/greenart7c3/nostrsigner/service/ZapstoreUpdater.kt +++ b/app/src/main/java/com/greenart7c3/nostrsigner/service/ZapstoreUpdater.kt @@ -66,21 +66,8 @@ class ZapstoreUpdater( UPDATE_RELAY_URLS.mapNotNull { RelayUrlNormalizer.normalizeOrNull(it) } private var timeoutJob: Job? = null - @Volatile - private var registered = false - init { - if (!registered) { - client.addConnectionListener(this) - registered = true - } - } - - fun dispose() { - if (registered) { - client.removeConnectionListener(this) - registered = false - } + client.addConnectionListener(this) } override fun onIncomingMessage(relay: IRelayClient, msgStr: String, msg: Message) {