Skip to content

Commit afac510

Browse files
authored
Merge pull request #299 from code-payments/fix/buy-kin-prevent-reset
fix(buykin): prevent currency initialization from resetting number he…
2 parents 16e0cc9 + 04bdc32 commit afac510

2 files changed

Lines changed: 10 additions & 2 deletions

File tree

app/src/main/java/com/getcode/view/main/getKin/BuyKinViewModel.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,10 @@ class BuyKinViewModel @Inject constructor(
7070

7171
val state = MutableStateFlow(State())
7272

73+
override fun canChangeCurrency(): Boolean {
74+
return false
75+
}
76+
7377
init {
7478
init()
7579

app/src/main/java/com/getcode/view/main/giveKin/BaseAmountCurrencyViewModel.kt

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,8 @@ abstract class BaseAmountCurrencyViewModel(
114114
abstract fun getAmountUiModel(): AmountUiModel
115115
abstract fun getAmountAnimatedInputUiModel(): AmountAnimatedInputUiModel
116116

117+
open fun canChangeCurrency(): Boolean = true
118+
117119
open fun init() {
118120
numberInputHelper.reset()
119121

@@ -138,8 +140,10 @@ abstract class BaseAmountCurrencyViewModel(
138140
balanceRepository.balanceFlow
139141
) { currencies, selectedCode, _, balance ->
140142
val currency = currencies.firstOrNull { it.code == selectedCode }
141-
if (currency?.code != getCurrencyUiModel().selectedCurrencyCode) {
142-
reset()
143+
if (canChangeCurrency()) {
144+
if (currency?.code != getCurrencyUiModel().selectedCurrencyCode) {
145+
reset()
146+
}
143147
}
144148
getModelsWithSelectedCurrency(
145149
currencies,

0 commit comments

Comments
 (0)