refactor: observe pairingUrl state

This commit is contained in:
2026-06-10 18:38:15 +02:00
parent a121d40bbd
commit 2bc92fca06
3 changed files with 9 additions and 14 deletions
+1
View File
@@ -2,6 +2,7 @@
<dictionary name="project"> <dictionary name="project">
<words> <words>
<w>Aead</w> <w>Aead</w>
<w>Bitrefill</w>
<w>Nbits</w> <w>Nbits</w>
<w>Nostr</w> <w>Nostr</w>
<w>Tink</w> <w>Tink</w>
@@ -36,20 +36,9 @@ private class AddConnectionState {
var nextBudgetId by mutableIntStateOf(0) var nextBudgetId by mutableIntStateOf(0)
var budgets by mutableStateOf(emptyList<BudgetDraft>()) var budgets by mutableStateOf(emptyList<BudgetDraft>())
// Converts the LocalDateTime expiry to a Unix epoch in seconds (#10) // Converts the LocalDateTime expiry to a Unix epoch in seconds
fun expiryEpochSeconds(): Long = fun expiryEpochSeconds(): Long =
expiry.atZone(ZoneId.systemDefault()).toEpochSecond() expiry.atZone(ZoneId.systemDefault()).toEpochSecond()
fun reset() {
description = ""
selectedPermissions = ALL_PERMISSIONS.filter { it.default }.map { it.serverKey }.toSet()
neverExpires = false
expiry = LocalDateTime.now().plusDays(30).withSecond(0).withNano(0)
showDatePicker = false
showTimePicker = false
nextBudgetId = 0
budgets = emptyList()
}
} }
// ── Sheet ───────────────────────────────────────────────────────────────────── // ── Sheet ─────────────────────────────────────────────────────────────────────
@@ -67,7 +56,7 @@ internal fun NwcAddConnectionSheet(
onDismiss : () -> Unit onDismiss : () -> Unit
) { ) {
val sheetState = rememberModalBottomSheetState(skipPartiallyExpanded = true) val sheetState = rememberModalBottomSheetState(skipPartiallyExpanded = true)
val state = remember { AddConnectionState() } // #9 val state = remember { AddConnectionState() }
if (state.showDatePicker) { if (state.showDatePicker) {
val initialMillis = state.expiry val initialMillis = state.expiry
@@ -33,6 +33,12 @@ fun NwcScreen(
val refresh = { viewModel.loadConnections(includeExpired = true) } val refresh = { viewModel.loadConnections(includeExpired = true) }
LaunchedEffect(pairingUrl) {
if (pairingUrl != null) {
viewModel.closeAddSheet()
}
}
Scaffold( Scaffold(
topBar = { topBar = {
TopAppBar( TopAppBar(
@@ -120,7 +126,6 @@ fun NwcScreen(
expiresAt = expiresAt, expiresAt = expiresAt,
budgets = budgets budgets = budgets
) )
viewModel.closeAddSheet()
}, },
onDismiss = { viewModel.closeAddSheet() } onDismiss = { viewModel.closeAddSheet() }
) )