From ea86c10adcf3df9f277887e75c4bb2bdf6fc6746 Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 1 Sep 2026 23:48:46 +0000 Subject: [PATCH] refactor: wrap the Block Relay press in launchSigner at the call site MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Replaces the onBlocked callback parameter added to AccountViewModel.blockRelay with the pattern the rest of the app already uses for "sign, then clean up the UI only if it worked" — accountViewModel.launchSigner { … } around both steps at the call site, as in AwardBadgeScreen's launchSigner { sendPost(); popBack() }. There are 187 such direct uses in ui/, so a bespoke callback parameter on the ViewModel was the odd one out. Behaviour is unchanged: blockRelay was itself defined as `= launchSigner { … }`, so the press already ran inside one and the dismissal already waited on a successful signature. This just drops a layer and the now-unused ViewModel method rather than leaving dead API behind. Co-Authored-By: Claude Opus 5 Claude-Session: https://claude.ai/code/session_01U2GsUAheZmAXv6vk4m7m9T --- .../compose/DisplayNotifyMessages.kt | 20 +++++++++---------- .../ui/screen/loggedIn/AccountViewModel.kt | 17 ---------------- 2 files changed, 10 insertions(+), 27 deletions(-) diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/service/relayClient/notifyCommand/compose/DisplayNotifyMessages.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/service/relayClient/notifyCommand/compose/DisplayNotifyMessages.kt index 304937a73b..25f5203281 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/service/relayClient/notifyCommand/compose/DisplayNotifyMessages.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/service/relayClient/notifyCommand/compose/DisplayNotifyMessages.kt @@ -60,17 +60,17 @@ fun DisplayNotifyMessages( onBlockRelay = if (accountViewModel.isWriteable()) { { - accountViewModel.blockRelay(request.relayUrl) { - // Only after the block is signed and published, never before: a refused - // or timed-out signature is swallowed without a toast, so dismissing up - // front would close the dialog on a relay that is still unblocked and - // leave the user no sign that anything failed. Leaving the prompt up is - // the feedback. + accountViewModel.launchSigner { + accountViewModel.account.blockRelay(request.relayUrl) + + // Reached only once the block is signed and published, because + // reportSignerErrors swallows a refused or timed-out signature without + // a toast: dismissing up front would close the dialog on a relay that + // is still unblocked and leave the user no sign anything failed. The + // prompt staying up is the feedback. // - // Every queued prompt from this relay goes at once, not just the one on - // screen: a paid relay files one NOTIFY per rejected AUTH, so dismissing - // only [request] would immediately re-open the dialog for a relay the - // user just asked us to stop talking to. + // Every queued prompt from the relay goes at once, not just the one on + // screen — a paid relay files one NOTIFY per rejected AUTH. requests.dismissAllFrom(request.relayUrl) } } diff --git a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/AccountViewModel.kt b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/AccountViewModel.kt index 3b9e74dcc9..e524ee8622 100644 --- a/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/AccountViewModel.kt +++ b/amethyst/src/main/java/com/vitorpamplona/amethyst/ui/screen/loggedIn/AccountViewModel.kt @@ -1919,23 +1919,6 @@ class AccountViewModel( fun unfollowRelayFeed(url: NormalizedRelayUrl) = launchSigner { account.unfollowRelayFeed(url) } - /** - * Blocks [url], running [onBlocked] only once the kind-10006 has actually been signed and - * published. - * - * The ordering matters: [reportSignerErrors] swallows a refused or timed-out signature - * (ManuallyUnauthorizedException, TimedOutException, CouldNotPerformException) with nothing but - * a log line, so a caller that cleaned up before the block landed would leave the user with an - * unblocked relay, no feedback, and whatever UI state it tore down already gone. - */ - fun blockRelay( - url: NormalizedRelayUrl, - onBlocked: () -> Unit = {}, - ) = launchSigner { - account.blockRelay(url) - onBlocked() - } - fun showWord(word: String) = launchSigner { account.showWord(word) } fun hideWord(word: String) = launchSigner { account.hideWord(word) }