Skip to content

Commit 87b2d22

Browse files
committed
fix: alerts for re-enable expired 2fa
1 parent bc9d161 commit 87b2d22

File tree

21 files changed

+294
-1171
lines changed

21 files changed

+294
-1171
lines changed

common/src/commonMain/composeResources/drawable/re_enable_two_factor.xml

Lines changed: 52 additions & 964 deletions
Large diffs are not rendered by default.

common/src/commonMain/composeResources/values/strings.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1676,4 +1676,5 @@
16761676
<string name="id_generate_amp_id">Generate AMP ID</string>
16771677
<string name="id_copy_amp_id">Copy AMP ID</string>
16781678
<string name="id_data_not_available">Data not available</string>
1679+
<string name="id_some_coins_are_no_longer_2fa_protected">Some coins are no longer 2FA protected.</string>
16791680
</resources>

common/src/commonMain/kotlin/com/blockstream/common/data/AlertType.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,5 @@ sealed class AlertType {
1313
data class Banner(val banner: com.blockstream.green.data.banner.Banner) : AlertType()
1414
data object FailedNetworkLogin : AlertType()
1515
data class LspStatus(val maintenance: Boolean) : AlertType()
16+
data object ReEnable2FA : AlertType()
1617
}

common/src/commonMain/kotlin/com/blockstream/common/extensions/Zip.kt

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,4 +66,30 @@ public fun <T1, T2, T3, T4, T5, T6, T7, T8, R> combine(
6666
args[6] as T7,
6767
args[7] as T8,
6868
)
69+
}
70+
71+
@Suppress("UNCHECKED_CAST")
72+
public fun <T1, T2, T3, T4, T5, T6, T7, T8, T9, R> combine(
73+
flow: Flow<T1>,
74+
flow2: Flow<T2>,
75+
flow3: Flow<T3>,
76+
flow4: Flow<T4>,
77+
flow5: Flow<T5>,
78+
flow6: Flow<T6>,
79+
flow7: Flow<T7>,
80+
flow8: Flow<T8>,
81+
flow9: Flow<T9>,
82+
transform: suspend (T1, T2, T3, T4, T5, T6, T7, T8, T9) -> R
83+
): Flow<R> = kotlinx.coroutines.flow.combine(flow, flow2, flow3, flow4, flow5, flow6, flow7, flow8, flow9) { args: Array<*> ->
84+
transform(
85+
args[0] as T1,
86+
args[1] as T2,
87+
args[2] as T3,
88+
args[3] as T4,
89+
args[4] as T5,
90+
args[5] as T6,
91+
args[6] as T7,
92+
args[7] as T8,
93+
args[8] as T9,
94+
)
6995
}

common/src/commonMain/kotlin/com/blockstream/common/gdk/GdkSession.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3070,7 +3070,7 @@ class GdkSession constructor(
30703070
scope.launch(context = logException(countly)) {
30713071
_expired2FAStateFlow.value = accounts.value.filter {
30723072

3073-
it.type == AccountType.STANDARD && !it.needs2faActivation(this@GdkSession) && getUnspentOutputs(
3073+
it.type == AccountType.STANDARD && getUnspentOutputs(
30743074
account = it,
30753075
isExpired = true
30763076
).unspentOutputs.isNotEmpty()

common/src/commonMain/kotlin/com/blockstream/common/models/overview/WalletOverviewViewModel.kt

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -220,18 +220,20 @@ class WalletOverviewViewModel(
220220
.stateIn(viewModelScope, SharingStarted.WhileSubscribed(), greenWallet),
221221
_twoFactorState,
222222
_systemMessage,
223+
session.expired2FA,
223224
session.failedNetworks,
224225
session.lightningSdkOrNull?.healthCheckStatus ?: MutableStateFlow(null),
225226
banner,
226227
hideWalletBackupAlert,
227228
session.walletTotalBalance
228-
) { greenWallet, twoFactorState, systemMessage, failedNetworkLogins, lspHeath, banner, hideWalletBackupAlert, walletTotalBalance ->
229+
) { greenWallet, twoFactorState, systemMessage, expired2FA, failedNetworkLogins, lspHeath, banner, hideWalletBackupAlert, walletTotalBalance ->
229230
listOfNotNull(
230231
if (!greenWallet.isRecoveryConfirmed && !hideWalletBackupAlert && walletTotalBalance > 0) AlertType.RecoveryIsUnconfirmed(
231232
withCloseButton = true
232233
) else null,
233234
twoFactorState,
234235
systemMessage,
236+
if (expired2FA.isNotEmpty()) AlertType.ReEnable2FA else null,
235237
if (greenWallet.isBip39Ephemeral) AlertType.EphemeralBip39 else null,
236238
banner?.let { AlertType.Banner(it) },
237239
if (session.isTestnet) AlertType.TestnetWarning else null,
@@ -286,7 +288,7 @@ class WalletOverviewViewModel(
286288
// Support only for Bitcoin
287289
session.bitcoinMultisig?.let { network ->
288290
session.twoFactorReset(network).filter { session.isConnected }.onEach {
289-
_twoFactorState.value = if (it != null && it.isActive == true) {
291+
_twoFactorState.value = if (it?.isActive == true) {
290292
if (it.isDisputed == true) {
291293
AlertType.Dispute2FA(network, it)
292294
} else {

common/src/commonMain/kotlin/com/blockstream/common/models/send/CreateTransactionViewModel.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -477,7 +477,7 @@ abstract class CreateTransactionViewModelAbstract(
477477

478478
session.pendingTransaction = null // clear pending transaction
479479
postSideEffect(SideEffects.Snackbar(StringHolder.create(Res.string.id_transaction_sent)))
480-
postSideEffect(SideEffects.NavigateToRoot(popTo = PopTo.Transact))
480+
postSideEffect(SideEffects.NavigateToTransactTab)
481481
} else {
482482
postSideEffect(
483483
SideEffects.Dialog(

common/src/commonMain/kotlin/com/blockstream/common/utils/SetupDevelopmentEnv.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
package com.blockstream.common.utils
22

33
import com.blockstream.common.data.DataState
4+
import com.blockstream.common.events.Events
45
import com.blockstream.common.models.login.LoginViewModel
56
import com.blockstream.common.models.login.LoginViewModelAbstract
7+
import com.blockstream.common.sideeffects.SideEffects
68
import com.blockstream.green.data.config.AppInfo
79
import com.rickclephas.kmp.observableviewmodel.launch
810
import kotlinx.coroutines.flow.first
@@ -40,6 +42,7 @@ class SetupDevelopmentEnv : KoinComponent {
4042
// If PIN credentials are available, attempt auto-login
4143
if (pinCredentialsState is DataState.Success) {
4244
viewModel.postEvent(LoginViewModel.LocalEvents.LoginWithPin(appInfo.developmentPin!!))
45+
viewModel.postEvent(Events.EventSideEffect(SideEffects.Snackbar(StringHolder(string = "Login with development PIN"))))
4346
}
4447
}
4548
}

compose/src/androidMain/kotlin/com/blockstream/compose/components/GreenAccountAsset.android.kt

Lines changed: 0 additions & 80 deletions
This file was deleted.

compose/src/androidMain/kotlin/com/blockstream/compose/components/GreenAlert.android.kt

Lines changed: 0 additions & 61 deletions
This file was deleted.

0 commit comments

Comments
 (0)