Skip to content

Commit

Permalink
631 Add feature toggle for storage alert feature (#637)
Browse files Browse the repository at this point in the history
  • Loading branch information
jeden authored Dec 6, 2024
1 parent b747bc1 commit 36fa19a
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
6 changes: 5 additions & 1 deletion FRW/Services/Manager/Config/RemoteConfig.swift
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ extension RemoteConfigManager {
case browser
case nftTransfer = "nft_transfer"
case hideBrowser = "hide_browser"
case insufficientBalance = "insufficient_balance"
case insufficientStorage = "insufficient_storage"
}

let freeGas: Bool
Expand All @@ -56,6 +58,8 @@ extension RemoteConfigManager {
let browser: Bool?
let nftTransfer: Bool?
let hideBrowser: Bool?
let insufficientBalance: Bool?
let insufficientStorage: Bool?
}

// MARK: - Payer
Expand Down Expand Up @@ -205,7 +209,7 @@ extension RemoteConfigManager {
return true
case .insufficientStorage:
// TODO: [AB] Not very elegant adding a dependency here, but implementing in a different way would probably require major refactoring
return WalletManager.shared.isStorageInsufficient
return WalletManager.shared.isStorageInsufficient && RemoteConfigManager.shared.config?.features.insufficientStorage ?? true
default:
return false
}
Expand Down
4 changes: 3 additions & 1 deletion FRW/Services/Manager/TransactionManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,9 @@ extension TransactionManager {

switch result.errorCode {
case .storageCapacityExceeded:
AlertViewController.showInsufficientStorageError(minimumBalance: WalletManager.shared.minimumStorageBalance.doubleValue)
if RemoteConfigManager.shared.config?.features.insufficientStorage ?? true {
AlertViewController.showInsufficientStorageError(minimumBalance: WalletManager.shared.minimumStorageBalance.doubleValue)
}
default:
break
}
Expand Down
8 changes: 7 additions & 1 deletion FRW/UI/Component/InsufficientStorageToastView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,11 @@ protocol InsufficientStorageToastViewModel: ObservableObject {
}

extension InsufficientStorageToastViewModel {
var showInsufficientFundsToast: Bool { self.variant != nil }
private var isInsufficientStorageEnabled: Bool { RemoteConfigManager.shared.config?.features.insufficientStorage ?? true }

var showInsufficientFundsToast: Bool {
self.isInsufficientStorageEnabled && self.variant != nil
}

func insufficientStorageCheckForMove(token: TokenType, from fromWallet: Contact.WalletType?, to toWallet: Contact.WalletType?) -> InsufficientStorageFailure? {
insufficientStorageCheck(amount: 0, token: token, from: fromWallet, to: toWallet)
Expand All @@ -42,6 +46,8 @@ extension InsufficientStorageToastViewModel {
}

private func insufficientStorageCheck(amount: Decimal, token: TokenType, from fromWallet: Contact.WalletType?, to toWallet: Contact.WalletType?) -> InsufficientStorageFailure? {
guard self.isInsufficientStorageEnabled == true else { return .none }

let wm = WalletManager.shared
guard wm.isStorageInsufficient == false else {
return .some(.beforeTransfer)
Expand Down

0 comments on commit 36fa19a

Please sign in to comment.