Skip to content

Commit bddc956

Browse files
committed
fix: disable send button on wo multisig
1 parent 6c9f98b commit bddc956

File tree

5 files changed

+13
-0
lines changed

5 files changed

+13
-0
lines changed

common/src/commonMain/kotlin/com/blockstream/common/models/GreenViewModel.kt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,9 @@ open class GreenViewModel constructor(
240240
private val _isHwWatchOnly = MutableStateFlow(false)
241241
val isHwWatchOnly = _isHwWatchOnly
242242

243+
private val _isMultisigWatchOnly = MutableStateFlow(false)
244+
val isMultisigWatchOnly = _isMultisigWatchOnly
245+
243246
private val _isQrWatchOnly = MutableStateFlow(false)
244247
val isQrWatchOnly = _isQrWatchOnly
245248

@@ -290,6 +293,8 @@ open class GreenViewModel constructor(
290293
_isWatchOnly.value = it
291294
_isHwWatchOnly.value = session.isHwWatchOnly
292295
_isQrWatchOnly.value = greenWalletOrNull?.isWatchOnlyQr ?: false
296+
297+
_isMultisigWatchOnly.value = it && !session.isHwWatchOnly
293298
}?.launchIn(this)
294299

295300
_event.onEach {

compose/src/commonMain/kotlin/com/blockstream/compose/components/GreenActionButton.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,13 @@ fun RowScope.GreenActionButton(
1717
text: StringResource,
1818
icon: ImageVector,
1919
onClick: () -> Unit,
20+
enabled: Boolean = true,
2021
modifier: Modifier = Modifier
2122
) {
2223
GreenCard(
2324
padding = 24,
2425
onClick = onClick,
26+
enabled = enabled,
2527
modifier = modifier.weight(1f)
2628
) {
2729
GreenColumn(

compose/src/commonMain/kotlin/com/blockstream/compose/components/TransactionActionButtons.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import com.blockstream.ui.components.GreenRow
1616
@Composable
1717
fun TransactionActionButtons(
1818
showBuyButton: Boolean,
19+
sendEnabled: Boolean,
1920
onBuy: () -> Unit,
2021
onSend: () -> Unit,
2122
onReceive: () -> Unit,
@@ -37,6 +38,7 @@ fun TransactionActionButtons(
3738
GreenActionButton(
3839
text = Res.string.id_send,
3940
icon = PhosphorIcons.Regular.ArrowLineUp,
41+
enabled = sendEnabled,
4042
onClick = onSend
4143
)
4244

compose/src/commonMain/kotlin/com/blockstream/compose/screens/assetaccounts/AssetAccountDetailsScreen.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ fun AssetAccountDetailsScreen(
5050
val totalBalance by viewModel.totalBalance.collectAsStateWithLifecycle()
5151
val totalBalanceFiat by viewModel.totalBalanceFiat.collectAsStateWithLifecycle()
5252
val showBuyButton by viewModel.showBuyButton.collectAsStateWithLifecycle()
53+
val isMultisigWatchOnly by viewModel.isMultisigWatchOnly.collectAsStateWithLifecycle()
5354
val hasMoreTransactions by viewModel.hasMoreTransactions.collectAsStateWithLifecycle()
5455

5556
val innerPadding = LocalInnerPadding.current
@@ -83,6 +84,7 @@ fun AssetAccountDetailsScreen(
8384
item(key = "ButtonsRow") {
8485
TransactionActionButtons(
8586
showBuyButton = showBuyButton,
87+
sendEnabled = !isMultisigWatchOnly,
8688
onBuy = { viewModel.postEvent(AssetAccountDetailsViewModel.LocalEvents.ClickBuy) },
8789
onSend = { viewModel.postEvent(AssetAccountDetailsViewModel.LocalEvents.ClickSend) },
8890
onReceive = { viewModel.postEvent(AssetAccountDetailsViewModel.LocalEvents.ClickReceive) }

compose/src/commonMain/kotlin/com/blockstream/compose/screens/overview/TransactScreen.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ fun TransactScreen(viewModel: TransactViewModelAbstract) {
3939
SetupScreen(viewModel = viewModel, withPadding = false, withBottomInsets = false) {
4040

4141
val transactions by viewModel.transactions.collectAsStateWithLifecycle()
42+
val isMultisigWatchOnly by viewModel.isMultisigWatchOnly.collectAsStateWithLifecycle()
4243
val innerPadding = LocalInnerPadding.current
4344
val listState = rememberLazyListState()
4445

@@ -56,6 +57,7 @@ fun TransactScreen(viewModel: TransactViewModelAbstract) {
5657
item(key = "ButtonsRow") {
5758
TransactionActionButtons(
5859
showBuyButton = true,
60+
sendEnabled = !isMultisigWatchOnly,
5961
onBuy = { viewModel.buy() },
6062
onSend = { viewModel.postEvent(NavigateDestinations.Send(greenWallet = viewModel.greenWallet)) },
6163
onReceive = {

0 commit comments

Comments
 (0)