Skip to content

Commit

Permalink
Open created vip support group on click
Browse files Browse the repository at this point in the history
  • Loading branch information
rafaelekol committed Jan 24, 2025
1 parent 7e12bd9 commit b1b4e96
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 23 deletions.
2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ dependencies {
implementation 'com.github.horizontalsystems:ethereum-kit-android:201296c'
implementation 'com.github.horizontalsystems:blockchain-fee-rate-kit-android:1d3bd49'
implementation 'com.github.horizontalsystems:binance-chain-kit-android:c1509a2'
implementation 'com.github.horizontalsystems:market-kit-android:8c9fc42'
implementation 'com.github.horizontalsystems:market-kit-android:0ea65ac'
implementation 'com.github.horizontalsystems:solana-kit-android:ce738d8'
implementation 'com.github.horizontalsystems:tron-kit-android:dc3dca7'
// Zcash SDK
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ interface ILocalStorage {
val balanceTabButtonsEnabledFlow: StateFlow<Boolean>
var nonRecommendedAccountAlertDismissedAccounts: Set<String>
var personalSupportEnabled: Boolean
var vipSupportEnabled: Boolean
var vipSupportLink: String?
var hideSuspiciousTransactions: Boolean
var pinRandomized: Boolean
var utxoExpertModeEnabled: Boolean
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ class LocalStorageManager(
private val BALANCE_AUTO_HIDE_ENABLED = "balance_auto_hide_enabled"
private val NON_RECOMMENDED_ACCOUNT_ALERT_DISMISSED_ACCOUNTS = "non_recommended_account_alert_dismissed_accounts"
private val PERSONAL_SUPPORT_ENABLED = "personal_support_enabled"
private val VIP_SUPPORT_ENABLED = "vip_support_enabled"
private val VIP_SUPPORT_LINK = "vip_support_link"
private val APP_ID = "app_id"
private val APP_AUTO_LOCK_INTERVAL = "app_auto_lock_interval"
private val HIDE_SUSPICIOUS_TX = "hide_suspicious_tx"
Expand Down Expand Up @@ -486,10 +486,10 @@ class LocalStorageManager(
preferences.edit().putBoolean(PERSONAL_SUPPORT_ENABLED, enabled).apply()
}

override var vipSupportEnabled: Boolean
get() = preferences.getBoolean(VIP_SUPPORT_ENABLED, false)
set(enabled) {
preferences.edit().putBoolean(VIP_SUPPORT_ENABLED, enabled).apply()
override var vipSupportLink: String?
get() = preferences.getString(VIP_SUPPORT_LINK, null)
set(link) {
preferences.edit().putString(VIP_SUPPORT_LINK, link).apply()
}

override var hideSuspiciousTransactions: Boolean
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ class MarketKitWrapper(
fun requestPersonalSupport(username: String): Single<Response<Void>> =
requestWithAuthToken { marketKit.requestPersonalSupport(it, username) }

fun requestVipSupport(username: String): Single<Response<Void>> =
fun requestVipSupport(username: String): Single<Map<String, String>> =
requestWithAuthToken { marketKit.requestVipSupport(it, username) }

// Stats
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import io.horizontalsystems.bankwallet.ui.compose.components.FormsInput
import io.horizontalsystems.bankwallet.ui.compose.components.InfoText
import io.horizontalsystems.bankwallet.ui.compose.components.VSpacer
import io.horizontalsystems.bankwallet.ui.extensions.BottomSheetHeader
import io.horizontalsystems.bankwallet.ui.helpers.LinkHelper

@OptIn(ExperimentalMaterial3Api::class)
@Composable
Expand Down Expand Up @@ -61,7 +62,7 @@ fun VipSupportBottomSheet(
onCloseClick = close,
iconTint = ColorFilter.tint(ComposeAppTheme.colors.jacob)
) {
if (uiState.showRequestForm) {
if (uiState.vipSupportLink == null) {
InfoText(
text = stringResource(R.string.Settings_PersonalSupport_EnterTelegramAccountDescription),
)
Expand Down Expand Up @@ -97,10 +98,7 @@ fun VipSupportBottomSheet(
.padding(start = 16.dp, end = 16.dp),
title = stringResource(R.string.Settings_PersonalSupport_OpenTelegram),
onClick = {
context.packageManager.getLaunchIntentForPackage("org.telegram.messenger")
?.let {
context.startActivity(it)
}
LinkHelper.openLinkInAppBrowser(context, uiState.vipSupportLink)
},
)
VSpacer(16.dp)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,14 @@ class VipSupportViewModel(
private var showError = false
private var showSpinner = false
private var buttonEnabled = false
private var showRequestForm = !localStorage.vipSupportEnabled
private var telegramGroupLink: String? = localStorage.vipSupportLink

override fun createState() = VipSupportModule.UiState(
contactName = contactName,
showError = showError,
showSpinner = showSpinner,
buttonEnabled = buttonEnabled,
showRequestForm = showRequestForm
vipSupportLink = telegramGroupLink
)

fun onUsernameChange(username: String) {
Expand All @@ -49,24 +49,29 @@ class VipSupportViewModel(
viewModelScope.launch(Dispatchers.IO) {
try {
val request = marketKitWrapper.requestVipSupport(contactName).await()
if (request.code() != 200) throw Exception("Error")
localStorage.vipSupportEnabled = true
showRequestForm = false
val groupLink = request["group_link"]
if (groupLink == null) {
throw Exception("Error")
} else {
localStorage.vipSupportLink = groupLink
telegramGroupLink = groupLink
showSpinner = false
buttonEnabled = true
emitState()
}
} catch (e: Throwable) {
showSpinner = false
buttonEnabled = true
showError = true
emitState()
return@launch
}
showSpinner = false
buttonEnabled = true
emitState()
}
}

fun showRequestForm() {
showRequestForm = true
telegramGroupLink = null
localStorage.vipSupportLink = null
emitState()
}

Expand All @@ -85,6 +90,6 @@ object VipSupportModule {
val showError: Boolean = false,
val showSpinner: Boolean = false,
val buttonEnabled: Boolean = false,
val showRequestForm: Boolean = false,
val vipSupportLink: String? = null,
)
}

0 comments on commit b1b4e96

Please sign in to comment.