Skip to content

Commit

Permalink
PERA-1364 :: Fix cards flag to show on staging testnet builds
Browse files Browse the repository at this point in the history
  • Loading branch information
michaeltchuang committed Jan 10, 2025
1 parent 59bac46 commit 6b430db
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import com.algorand.android.BuildConfig.DISCOVER_BROWSE_DAPP_TESTNET_URL
import com.algorand.android.BuildConfig.DISCOVER_MAINNET_URL
import com.algorand.android.BuildConfig.DISCOVER_TESTNET_URL
import com.algorand.android.usecase.GetIsActiveNodeTestnetUseCase
import com.algorand.android.usecase.GetIsProductionReleaseUseCase
import com.algorand.common.remoteconfig.domain.usecase.IMMERSVE_BUTTON_TOGGLE
import com.algorand.common.remoteconfig.domain.usecase.IsFeatureToggleEnabled
import com.algorand.common.remoteconfig.domain.usecase.STAKING_BUTTON_TOGGLE
Expand All @@ -28,6 +29,7 @@ import javax.inject.Inject

@HiltViewModel
class CoreActionsTabBarViewModel @Inject constructor(
private val getIsProductionReleaseUseCase: GetIsProductionReleaseUseCase,
private val getIsActiveNodeTestnetUseCase: GetIsActiveNodeTestnetUseCase,
private val isFeatureToggleEnabled: IsFeatureToggleEnabled
) : ViewModel() {
Expand All @@ -36,7 +38,8 @@ class CoreActionsTabBarViewModel @Inject constructor(
val viewState get() = _viewState.asStateFlow()

fun initViewState() {
val isImmersveToggleEnabled = isFeatureToggleEnabled(IMMERSVE_BUTTON_TOGGLE) && !isConnectedToTestnet()
val isImmersveToggleEnabled = isFeatureToggleEnabled(IMMERSVE_BUTTON_TOGGLE) &&
!(isConnectedToTestnet() && isProdReleaseVariant())
val isStakingToggleEnabled = isFeatureToggleEnabled(STAKING_BUTTON_TOGGLE)
_viewState.value = ViewState.Content(isImmersveToggleEnabled, isStakingToggleEnabled)
}
Expand All @@ -61,6 +64,10 @@ class CoreActionsTabBarViewModel @Inject constructor(
return getIsActiveNodeTestnetUseCase.invoke()
}

fun isProdReleaseVariant(): Boolean {
return getIsProductionReleaseUseCase.invoke()
}

sealed interface ViewState {
data object Idle : ViewState
data class Content(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/*
* Copyright 2022 Pera Wallet, LDA
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License
*/

package com.algorand.android.usecase

import com.algorand.android.BuildConfig
import javax.inject.Inject

// TODO: Update this class after deciding on where is the correct place to get the active node
class GetIsProductionReleaseUseCase @Inject constructor() {
operator fun invoke(): Boolean {
// return true if prodRelease variant
return !BuildConfig.DEBUG && BuildConfig.FLAVOR == "prod"
}
}

0 comments on commit 6b430db

Please sign in to comment.