refactor: wrap the Block Relay press in launchSigner at the call site

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 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01U2GsUAheZmAXv6vk4m7m9T
This commit is contained in:
Claude
2026-09-01 23:48:46 +00:00
parent b8899ec7ff
commit ea86c10adc
2 changed files with 10 additions and 27 deletions
@@ -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)
}
}
@@ -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) }