Skip to content

Commit

Permalink
(android) Prevent claiming address if wallet has no channels
Browse files Browse the repository at this point in the history
  • Loading branch information
dpad85 committed Jul 10, 2024
1 parent ebf5681 commit 47a32eb
Showing 1 changed file with 12 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.material.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.collectAsState
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.setValue
Expand All @@ -47,6 +48,7 @@ import fr.acinq.phoenix.android.components.PhoenixIcon
import fr.acinq.phoenix.android.components.settings.Setting
import fr.acinq.phoenix.android.utils.copyToClipboard
import fr.acinq.phoenix.android.utils.datastore.InternalDataRepository
import fr.acinq.phoenix.data.canRequestLiquidity
import fr.acinq.phoenix.managers.PeerManager
import kotlinx.coroutines.delay
import kotlinx.coroutines.flow.first
Expand Down Expand Up @@ -137,6 +139,9 @@ private fun ClaimAddressButton(
state: ClaimAddressState,
onClaim: () -> Unit,
) {
val channels by business.peerManager.channelsFlow.collectAsState()
val canClaimAddress = channels.canRequestLiquidity()

when (state) {
is ClaimAddressState.Init -> {
Setting(
Expand All @@ -152,7 +157,13 @@ private fun ClaimAddressButton(
subtitle = {
Text(text = stringResource(id = R.string.bip353_subtitle))
Spacer(modifier = Modifier.height(8.dp))
FilledButton(text = stringResource(id = R.string.bip353_claim_button), onClick = onClaim, padding = PaddingValues(horizontal = 12.dp, vertical = 8.dp))
FilledButton(
text = stringResource(id = R.string.bip353_claim_button),
onClick = onClaim,
padding = PaddingValues(horizontal = 12.dp, vertical = 8.dp),
enabled = canClaimAddress,
enabledEffect = true,
)
}
)
}
Expand Down

0 comments on commit 47a32eb

Please sign in to comment.