diff --git a/android/app/src/main/java/com/siriusdevops/onionwire/ui/WalletChildStatusText.kt b/android/app/src/main/java/com/siriusdevops/onionwire/ui/WalletChildStatusText.kt index ebbbd5d..57ee94b 100644 --- a/android/app/src/main/java/com/siriusdevops/onionwire/ui/WalletChildStatusText.kt +++ b/android/app/src/main/java/com/siriusdevops/onionwire/ui/WalletChildStatusText.kt @@ -394,30 +394,6 @@ fun chainStorageBlockedReason( } } -enum class CuprateMode { - MainnetPruned, - MainnetFull, - Testnet, -} - -fun selectedCuprateMode(inProcess: Boolean, mainnet: Boolean, prune: Boolean): CuprateMode? = - when { - !inProcess -> null - !mainnet -> CuprateMode.Testnet - prune -> CuprateMode.MainnetPruned - else -> CuprateMode.MainnetFull - } - -/** - * Tapping a mode used to only persist `ChainConfig`, which looked like a no-op - * besides the storage line. Start when the storage floor would allow Start and - * a launch is not already in flight. - */ -fun shouldStartAfterSelectingChain( - storageBlocked: String?, - starting: Boolean, -): Boolean = storageBlocked == null && !starting - /** * Bytes as a screen-sized string. Binary units (a "GB" that is really a GiB is how * a store that needs 3 GiB ends up on a device with 2.8). diff --git a/android/app/src/main/java/com/siriusdevops/onionwire/ui/WalletScreen.kt b/android/app/src/main/java/com/siriusdevops/onionwire/ui/WalletScreen.kt index a67d8de..e29576c 100644 --- a/android/app/src/main/java/com/siriusdevops/onionwire/ui/WalletScreen.kt +++ b/android/app/src/main/java/com/siriusdevops/onionwire/ui/WalletScreen.kt @@ -258,23 +258,6 @@ fun WalletScreen( scope.launch { vm.setInProcessCuprate(bins, mainnet, prune) .onFailure { daemonError = it.message ?: it.toString() } - .onSuccess { - // The mode buttons used to only persist the choice, - // which read as a no-op besides the storage line. - // Start is still the core launch; tapping a mode - // fires it when the storage gate would allow Start. - if (shouldStartAfterSelectingChain( - chainStorageBlockedReason( - vm.chainFreeBytes(), - mainnet = mainnet, - prune = prune, - ), - starting = starting, - ) - ) { - vm.startWalletChild() - } - } } }, starting = starting, @@ -751,34 +734,30 @@ private fun WalletChildCard( ) { Text("Receive-only") } } - // Tapping a mode stores it and, when the storage floor allows, - // starts the node. Filled = the stored choice. + // The third chain source. Never a default: selecting it is what stores + // `ChainChoice.InProcessCuprate`, and the warning below is what the user + // reads before Start. Spacer(Modifier.height(8.dp)) - val mode = selectedCuprateMode( - inProcess = inProcess, - mainnet = chain?.mainnet == true, - prune = chain?.prune == true, - ) - CuprateModeButton( - label = "Mainnet pruned", - selected = mode == CuprateMode.MainnetPruned, - testTag = "wallet-chain-mainnet-pruned", + OutlinedButton( onClick = { onInProcessNode(true, true) }, - ) + modifier = Modifier + .fillMaxWidth() + .testTag("wallet-chain-mainnet-pruned"), + ) { Text("Mainnet pruned") } Spacer(Modifier.height(4.dp)) - CuprateModeButton( - label = "Mainnet full", - selected = mode == CuprateMode.MainnetFull, - testTag = "wallet-chain-mainnet-full", + OutlinedButton( onClick = { onInProcessNode(true, false) }, - ) + modifier = Modifier + .fillMaxWidth() + .testTag("wallet-chain-mainnet-full"), + ) { Text("Mainnet full") } Spacer(Modifier.height(4.dp)) - CuprateModeButton( - label = "Testnet (experimental)", - selected = mode == CuprateMode.Testnet, - testTag = "wallet-chain-in-process", + OutlinedButton( onClick = { onInProcessNode(false, false) }, - ) + modifier = Modifier + .fillMaxWidth() + .testTag("wallet-chain-in-process"), + ) { Text("Testnet (experimental)") } if (inProcess) { Spacer(Modifier.height(8.dp)) @@ -857,23 +836,6 @@ private fun WalletChildCard( } } -@Composable -private fun CuprateModeButton( - label: String, - selected: Boolean, - testTag: String, - onClick: () -> Unit, -) { - val modifier = Modifier - .fillMaxWidth() - .testTag(testTag) - if (selected) { - Button(onClick = onClick, modifier = modifier) { Text(label) } - } else { - OutlinedButton(onClick = onClick, modifier = modifier) { Text(label) } - } -} - /** * The SDK record as the pure model `WalletChildStatusText.kt` renders. Field for * field, nothing inferred. diff --git a/android/app/src/test/java/com/siriusdevops/onionwire/ui/WalletChildStatusTextTest.kt b/android/app/src/test/java/com/siriusdevops/onionwire/ui/WalletChildStatusTextTest.kt index 7627175..f6cec47 100644 --- a/android/app/src/test/java/com/siriusdevops/onionwire/ui/WalletChildStatusTextTest.kt +++ b/android/app/src/test/java/com/siriusdevops/onionwire/ui/WalletChildStatusTextTest.kt @@ -391,32 +391,6 @@ class WalletChildStatusTextTest { assertTrue(why!!, why.contains("280.0 GiB")) } - @Test - fun selecting_pruned_highlights_that_mode() { - assertEquals( - CuprateMode.MainnetPruned, - selectedCuprateMode(inProcess = true, mainnet = true, prune = true), - ) - assertEquals( - CuprateMode.MainnetFull, - selectedCuprateMode(inProcess = true, mainnet = true, prune = false), - ) - assertEquals( - CuprateMode.Testnet, - selectedCuprateMode(inProcess = true, mainnet = false, prune = false), - ) - assertNull(selectedCuprateMode(inProcess = false, mainnet = true, prune = true)) - } - - @Test - fun selecting_a_mode_starts_unless_storage_or_an_in_flight_start_blocks_it() { - assertTrue(shouldStartAfterSelectingChain(storageBlocked = null, starting = false)) - assertFalse( - shouldStartAfterSelectingChain(storageBlocked = "Not enough space", starting = false), - ) - assertFalse(shouldStartAfterSelectingChain(storageBlocked = null, starting = true)) - } - @Test fun the_storage_line_reports_the_measured_number() { val line = chainStorageLine(41L * 1024 * 1024 * 1024)