Skip to content

Commit 00b2273

Browse files
ovitrifclaude
andcommitted
refactor: use ToastText.Parameterized in ExternalNodeViewModel
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 5237794 commit 00b2273

1 file changed

Lines changed: 9 additions & 14 deletions

File tree

app/src/main/java/to/bitkit/ui/screens/transfer/external/ExternalNodeViewModel.kt

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
package to.bitkit.ui.screens.transfer.external
22

3-
import android.content.Context
43
import androidx.lifecycle.ViewModel
54
import androidx.lifecycle.viewModelScope
65
import dagger.hilt.android.lifecycle.HiltViewModel
7-
import dagger.hilt.android.qualifiers.ApplicationContext
86
import kotlinx.coroutines.flow.MutableSharedFlow
97
import kotlinx.coroutines.flow.MutableStateFlow
108
import kotlinx.coroutines.flow.asSharedFlow
@@ -35,7 +33,6 @@ import javax.inject.Inject
3533
@Suppress("LongParameterList")
3634
@HiltViewModel
3735
class ExternalNodeViewModel @Inject constructor(
38-
@ApplicationContext private val context: Context,
3936
private val walletRepo: WalletRepo,
4037
private val lightningRepo: LightningRepo,
4138
private val settingsStore: SettingsStore,
@@ -98,15 +95,13 @@ class ExternalNodeViewModel @Inject constructor(
9895
val maxAmount = _uiState.value.amount.max
9996

10097
if (sats > maxAmount) {
101-
viewModelScope.launch {
102-
toaster.error(
103-
title = ToastText(R.string.lightning__spending_amount__error_max__title),
104-
body = ToastText(
105-
context.getString(R.string.lightning__spending_amount__error_max__description)
106-
.replace("{amount}", maxAmount.formatToModernDisplay())
107-
),
108-
)
109-
}
98+
toaster.error(
99+
title = ToastText(R.string.lightning__spending_amount__error_max__title),
100+
body = ToastText(
101+
R.string.lightning__spending_amount__error_max__description,
102+
mapOf("amount" to maxAmount.formatToModernDisplay()),
103+
),
104+
)
110105
return
111106
}
112107

@@ -193,8 +188,8 @@ class ExternalNodeViewModel @Inject constructor(
193188
toaster.error(
194189
title = ToastText(R.string.lightning__error_channel_purchase),
195190
body = ToastText(
196-
context.getString(R.string.lightning__error_channel_setup_msg)
197-
.replace("{raw}", error)
191+
R.string.lightning__error_channel_setup_msg,
192+
mapOf("raw" to error),
198193
),
199194
)
200195
}

0 commit comments

Comments
 (0)