Skip to content

Commit

Permalink
MOB-2133 - Add feature flag to control buy domain feature (#617)
Browse files Browse the repository at this point in the history
  • Loading branch information
Oleg-Pecheneg authored Jul 29, 2024
1 parent b9893b9 commit 9c446c8
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ extension HomeWalletView {
switch self {
case .send:
return "send"
case .buy:
return "buy"
case .buy(let enabled):
return "buy_\(enabled)"
case .receive:
return "receive"
case .profile(let enabled):
Expand All @@ -73,7 +73,7 @@ extension HomeWalletView {
}

case send
case buy
case buy(enabled: Bool)
case receive
case profile(enabled: Bool)
case more
Expand Down Expand Up @@ -134,9 +134,9 @@ extension HomeWalletView {

var isDimmed: Bool {
switch self {
case .send, .buy, .receive, .more:
case .send, .receive, .more:
return false
case .profile(let enabled):
case .buy(let enabled), .profile(let enabled):
return !enabled
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ private extension HomeWalletView {
}

func walletActions() -> [WalletAction] {
var actions: [WalletAction] = [.buy]
var actions: [WalletAction] = [.buy(enabled: viewModel.isBuyButtonEnabled)]
if viewModel.isSendCryptoEnabled {
actions.append(.send)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,13 +98,16 @@ extension HomeWalletView {
}))
}
case .buy:
if appContext.udFeatureFlagsService.valueFor(flag: .isBuyCryptoEnabled) {
if appContext.udFeatureFlagsService.valueFor(flag: .isBuyCryptoEnabled),
appContext.udFeatureFlagsService.valueFor(flag: .isBuyDomainEnabled) {
router.pullUp = .default(.homeWalletBuySelectionPullUp(selectionCallback: { [weak self] buyOption in
self?.router.pullUp = nil
self?.didSelectBuyOption(buyOption)
}))
} else {
} else if appContext.udFeatureFlagsService.valueFor(flag: .isBuyDomainEnabled) {
didSelectBuyOption(.domains)
} else {
didSelectBuyOption(.crypto)
}
case .more:
return
Expand Down Expand Up @@ -175,6 +178,11 @@ extension HomeWalletView {
return false
}
}

var isBuyButtonEnabled: Bool {
let featureFlagsService = appContext.udFeatureFlagsService
return featureFlagsService.valueFor(flag: .isBuyCryptoEnabled) || featureFlagsService.valueFor(flag: .isBuyDomainEnabled)
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ enum UDFeatureFlag: String, CaseIterable {
case communityMediaEnabled = "ecommerce-service-users-enable-chat-community-media"
case isBuyCryptoEnabled = "mobile-buy-crypto-enabled"
case isSendCryptoEnabled = "mobile-send-crypto-enabled"
case isBuyDomainEnabled = "mobile-buy-domain-enabled"

case isMPCWalletEnabled = "mobile-mpc-wallet-enabled"
case isMPCSendCryptoEnabled = "mobile-mpc-send-crypto-enabled"
Expand All @@ -30,7 +31,7 @@ enum UDFeatureFlag: String, CaseIterable {
switch self {
case .communityMediaEnabled, .isBuyCryptoEnabled, .isMPCMessagingEnabled, .isMPCWCNativeEnabled, .isMaintenanceFullEnabled, .isMaintenanceOKLinkEnabled, .isMaintenanceProfilesAPIEnabled, .isMaintenanceEcommEnabled, .isMaintenanceInfuraEnabled, .isMaintenanceMPCEnabled:
return false
case .isSendCryptoEnabled, .isMPCWalletEnabled, .isMPCSendCryptoEnabled, .isMPCSignatureEnabled, .isMPCPurchaseEnabled:
case .isSendCryptoEnabled, .isMPCWalletEnabled, .isMPCSendCryptoEnabled, .isMPCSignatureEnabled, .isMPCPurchaseEnabled, .isBuyDomainEnabled:
return true
}
}
Expand All @@ -40,7 +41,7 @@ enum UDFeatureFlag: String, CaseIterable {
switch self {
case .isMaintenanceFullEnabled, .isMaintenanceOKLinkEnabled, .isMaintenanceProfilesAPIEnabled, .isMaintenanceEcommEnabled, .isMaintenanceInfuraEnabled, .isMaintenanceMPCEnabled:
return true
case .isSendCryptoEnabled, .isMPCWalletEnabled, .isMPCSendCryptoEnabled, .isMPCSignatureEnabled, .isMPCPurchaseEnabled, .communityMediaEnabled, .isBuyCryptoEnabled, .isMPCMessagingEnabled, .isMPCWCNativeEnabled:
case .isSendCryptoEnabled, .isMPCWalletEnabled, .isMPCSendCryptoEnabled, .isMPCSignatureEnabled, .isMPCPurchaseEnabled, .communityMediaEnabled, .isBuyCryptoEnabled, .isMPCMessagingEnabled, .isMPCWCNativeEnabled, .isBuyDomainEnabled:
return false
}
}
Expand Down

0 comments on commit 9c446c8

Please sign in to comment.