Skip to content

Commit

Permalink
fix set result crash
Browse files Browse the repository at this point in the history
  • Loading branch information
polstianka committed Oct 31, 2024
1 parent 2b1d1f1 commit 8d7838e
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 7 deletions.
4 changes: 2 additions & 2 deletions apps/wallet/api/src/main/java/com/tonapps/wallet/api/API.kt
Original file line number Diff line number Diff line change
Expand Up @@ -481,8 +481,8 @@ class API(
}
}

fun batteryVerifyPurchasePromo(testnet: Boolean, code: String): Boolean {
return withRetry {
suspend fun batteryVerifyPurchasePromo(testnet: Boolean, code: String): Boolean = withContext(Dispatchers.IO) {
withRetry {
battery(testnet).verifyPurchasePromo(code)
true
} ?: false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ sealed class Item(type: Int) : BaseListItem(type) {
get() = promoState is PromoState.Error

val promoCode: String?
get() = appliedPromo ?: code
get() = code ?: appliedPromo
}

data class Settings(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -507,7 +507,19 @@ class RootViewModel(
}

private suspend fun openBattery(wallet: WalletEntity, route: DeepLinkRoute.Battery) {
openScreen(BatteryScreen.newInstance(wallet, route.promocode))
val promoCode = route.promocode
if (promoCode.isNullOrEmpty()) {
openScreen(BatteryScreen.newInstance(wallet))
} else {
loading(true)
val validCode = api.batteryVerifyPurchasePromo(wallet.testnet, promoCode)
loading(false)
if (validCode) {
openScreen(BatteryScreen.newInstance(wallet, promoCode))
} else {
toast(Localization.wrong_promocode)
}
}
}

private suspend fun openTokenViewer(wallet: WalletEntity, route: DeepLinkRoute.Jetton) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import androidx.appcompat.widget.AppCompatTextView
import androidx.core.view.doOnNextLayout
import androidx.lifecycle.lifecycleScope
import androidx.recyclerview.widget.RecyclerView
import com.google.firebase.crashlytics.FirebaseCrashlytics
import com.tonapps.extensions.getParcelableCompat
import com.tonapps.tonkeeper.core.history.list.HistoryAdapter
import com.tonapps.tonkeeper.extensions.getTitle
Expand Down Expand Up @@ -152,9 +153,13 @@ class SendTransactionScreen(wallet: WalletEntity) : WalletContextScreen(R.layout
}

private fun setErrorResult(error: BridgeException) {
setResult(Bundle().apply {
putParcelable(ERROR, error)
})
try {
setResult(Bundle().apply {
putParcelable(ERROR, error)
})
} catch (e: Throwable) {
FirebaseCrashlytics.getInstance().recordException(Throwable("Error: $error\nAppUrl: ${args.request.appUri}", e))
}
}

private fun setSuccessTask(boc: String) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,7 @@
<string name="disconnect_all_apps_confirm">Отключить все приложения?</string>
<string name="connected_apps_empty">Нет подключённых приложений</string>
<string name="send_all_balance">Вы уверены, что хотите отправить весь свой баланс?</string>
<string name="wrong_promocode">Введённый промокод недействителен</string>



Expand Down
1 change: 1 addition & 0 deletions apps/wallet/localization/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -543,4 +543,5 @@
<string name="disconnect_all_apps_confirm">Disconnect All Apps?</string>
<string name="connected_apps_empty">No connected apps</string>
<string name="send_all_balance">Are you sure you want to send all your balance?</string>
<string name="wrong_promocode">The entered code is not valid</string>
</resources>

0 comments on commit 8d7838e

Please sign in to comment.