Skip to content

Commit 6b32765

Browse files
committed
chore: fix lint
1 parent b41b715 commit 6b32765

File tree

3 files changed

+11
-7
lines changed

3 files changed

+11
-7
lines changed

app/src/main/java/to/bitkit/ui/screens/wallets/send/SendFeeCustomScreen.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import androidx.compose.foundation.layout.padding
88
import androidx.compose.runtime.Composable
99
import androidx.compose.runtime.LaunchedEffect
1010
import androidx.compose.runtime.getValue
11+
import androidx.compose.runtime.rememberUpdatedState
1112
import androidx.compose.ui.Modifier
1213
import androidx.compose.ui.platform.testTag
1314
import androidx.compose.ui.res.stringResource
@@ -38,11 +39,12 @@ fun SendFeeCustomScreen(
3839
onContinue: (TransactionSpeed) -> Unit,
3940
viewModel: SendFeeViewModel,
4041
) {
42+
val currentOnContinue by rememberUpdatedState(onContinue)
4143
val uiState by viewModel.uiState.collectAsStateWithLifecycle()
4244

4345
LaunchedEffect(uiState.isCustomFeeValid, uiState.custom) {
4446
if (uiState.isCustomFeeValid == true) {
45-
uiState.custom?.let { onContinue(it) }
47+
uiState.custom?.let { currentOnContinue(it) }
4648
}
4749
}
4850

app/src/main/java/to/bitkit/ui/screens/wallets/send/SendFeeViewModel.kt

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@ import to.bitkit.ui.shared.toast.ToastEventBus
2222
import to.bitkit.viewmodels.SendUiState
2323
import javax.inject.Inject
2424

25-
const val MAX_INPUT_VALUE = 999u
25+
private const val MAX_DIGITS = 3
26+
private const val MAX_VALUE = 999u
27+
private const val MAX_RATIO = 0.5
2628

2729
@HiltViewModel
2830
class SendFeeViewModel @Inject constructor(
@@ -35,7 +37,7 @@ class SendFeeViewModel @Inject constructor(
3537
val uiState = _uiState.asStateFlow()
3638

3739
private lateinit var sendUiState: SendUiState
38-
private var maxSatsPerVByte: UInt = MAX_INPUT_VALUE
40+
private var maxSatsPerVByte: UInt = MAX_VALUE
3941
private var maxFee: ULong = 0u
4042

4143
fun init(sendUiState: SendUiState) {
@@ -67,7 +69,7 @@ class SendFeeViewModel @Inject constructor(
6769

6870
private fun getFeeLimit(): ULong {
6971
val totalBalance = walletRepo.balanceState.value.totalOnchainSats
70-
val halfBalance = (totalBalance.toDouble() * 0.5).toULong()
72+
val halfBalance = (totalBalance.toDouble() * MAX_RATIO).toULong()
7173
val remainingFunds = maxOf(0u, totalBalance - sendUiState.amount)
7274
return minOf(halfBalance, remainingFunds)
7375
}
@@ -76,7 +78,7 @@ class SendFeeViewModel @Inject constructor(
7678
val currentInput = _uiState.value.input
7779
val newInput = when (key) {
7880
KEY_DELETE -> if (currentInput.isNotEmpty()) currentInput.dropLast(1) else ""
79-
else -> if (currentInput.length < 3) (currentInput + key).trimStart('0') else currentInput
81+
else -> if (currentInput.length < MAX_DIGITS) (currentInput + key).trimStart('0') else currentInput
8082
}
8183

8284
val satsPerVByte = newInput.toUIntOrNull() ?: 0u
@@ -157,7 +159,7 @@ class SendFeeViewModel @Inject constructor(
157159
maxSatsPerVByte = if (feeFor1SatPerVByte > 0uL) {
158160
(maxFee / feeFor1SatPerVByte).toUInt().coerceAtLeast(1u)
159161
} else {
160-
MAX_INPUT_VALUE
162+
MAX_VALUE
161163
}
162164
}
163165
}

config/detekt/detekt.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -693,7 +693,7 @@ style:
693693
active: false
694694
ReturnCount:
695695
active: true
696-
max: 2
696+
max: 5
697697
excludedFunctions:
698698
- 'equals'
699699
excludeLabeled: false

0 commit comments

Comments
 (0)