Skip to content

Commit

Permalink
Fix unable to search price alert assets
Browse files Browse the repository at this point in the history
  • Loading branch information
gemcoder21 committed Sep 20, 2024
1 parent 44836f8 commit 67418b5
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 22 deletions.
4 changes: 2 additions & 2 deletions Gem.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -3203,7 +3203,7 @@
LD_RUNPATH_SEARCH_PATHS = "@executable_path/Frameworks";
"LD_RUNPATH_SEARCH_PATHS[sdk=macosx*]" = "@executable_path/../Frameworks";
MACOSX_DEPLOYMENT_TARGET = 12.0;
MARKETING_VERSION = 1.3.48;
MARKETING_VERSION = 1.3.49;
OTHER_LDFLAGS = "";
PRODUCT_BUNDLE_IDENTIFIER = com.gemwallet.ios;
"PRODUCT_BUNDLE_IDENTIFIER[sdk=iphoneos*]" = com.gemwallet.ios;
Expand Down Expand Up @@ -3256,7 +3256,7 @@
LD_RUNPATH_SEARCH_PATHS = "@executable_path/Frameworks";
"LD_RUNPATH_SEARCH_PATHS[sdk=macosx*]" = "@executable_path/../Frameworks";
MACOSX_DEPLOYMENT_TARGET = 12.0;
MARKETING_VERSION = 1.3.48;
MARKETING_VERSION = 1.3.49;
OTHER_LDFLAGS = "";
PRODUCT_BUNDLE_IDENTIFIER = com.gemwallet.ios;
"PRODUCT_BUNDLE_IDENTIFIER[sdk=iphoneos*]" = com.gemwallet.ios;
Expand Down
1 change: 0 additions & 1 deletion Gem/Assets/Scenes/SelectAssetScene.swift
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,6 @@ struct SelectAssetScene: View {
.modifier(ToastModifier(isPresenting: $isPresentingCopyMessage, value: isPresentingCopyMessageValue ?? "", systemImage: SystemImage.copy))
.listSectionSpacing(.compact)
.navigationBarTitle(model.title)

}
}

Expand Down
2 changes: 1 addition & 1 deletion Gem/Assets/ViewModels/SelectAssetViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class SelectAssetViewModel {
var state: StateViewType<[AssetFull]> = .noData
var filterModel: AssetsFilterViewModel

private var selectAssetAction: AssetAction?
var selectAssetAction: AssetAction?

init(
wallet: Wallet,
Expand Down
2 changes: 1 addition & 1 deletion Gem/Price Alerts/Asset/PriceAlertService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ struct PriceAlertService {
try await apiService.getPriceAlerts(deviceId: securePreferences.getDeviceId())
}

func addPriceAlert(assetId: String, autoEnable: Bool) async throws {
func addPriceAlert(assetId: String, autoEnable: Bool = false) async throws {
if autoEnable {
if !preferences.isPriceAlertsEnabled {
preferences.isPriceAlertsEnabled = true
Expand Down
32 changes: 17 additions & 15 deletions Gem/Price Alerts/Navigation/AddAssetPriceAlertNavigationStack.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,28 +7,24 @@ import Primitives
struct AddAssetPriceAlertsNavigationStack: View {

@Environment(\.dismiss) private var dismiss
@Environment(\.keystore) private var keystore
@Environment(\.assetsService) private var assetsService
@Environment(\.walletsService) private var walletsService

let model: AddAssetPriceAlertsViewModel
@State private var model: AddAssetPriceAlertsViewModel
@State private var selectAssetModel: SelectAssetViewModel

init(
model: AddAssetPriceAlertsViewModel,
selectAssetModel: SelectAssetViewModel
) {
self.model = model
self.selectAssetModel = selectAssetModel
}

@State var navigationPath = NavigationPath()

var body: some View {
NavigationStack(path: $navigationPath) {
SelectAssetScene(
model: SelectAssetViewModel(
wallet: keystore.currentWallet!,
keystore: keystore,
selectType: .priceAlert,
assetsService: assetsService,
walletsService: walletsService,
selectAssetAction: {
model.onSelectAsset($0)
dismiss()
}
),
model: selectAssetModel,
isPresentingAddToken: .constant(false),
navigationPath: $navigationPath
)
Expand All @@ -41,5 +37,11 @@ struct AddAssetPriceAlertsNavigationStack: View {
}
.navigationBarTitleDisplayMode(.inline)
}
.task {
self.selectAssetModel.selectAssetAction = {
model.onSelectAsset($0)
dismiss()
}
}
}
}
14 changes: 13 additions & 1 deletion Gem/Price Alerts/Navigation/PriceAlertsNavigationView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ import Style
struct PriceAlertsNavigationView: View {

@Environment(\.dismiss) private var dismiss
@Environment(\.keystore) private var keystore
@Environment(\.assetsService) private var assetsService
@Environment(\.walletsService) private var walletsService
@Environment(\.priceService) private var priceService
@Environment(\.priceAlertService) private var priceAlertService

Expand All @@ -32,7 +35,16 @@ struct PriceAlertsNavigationView: View {
}
.sheet(isPresented: $isPresentingAddAsset) {
AddAssetPriceAlertsNavigationStack(
model: AddAssetPriceAlertsViewModel(priceAlertService: priceAlertService)
model: AddAssetPriceAlertsViewModel(
priceAlertService: priceAlertService
),
selectAssetModel: SelectAssetViewModel(
wallet: keystore.currentWallet!,
keystore: keystore,
selectType: .priceAlert,
assetsService: assetsService,
walletsService: walletsService
)
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ struct AddAssetPriceAlertsViewModel {

func onSelectAsset(_ asset: Asset) {
Task {
try await priceAlertService.addPriceAlert(assetId: asset.id.identifier, autoEnable: true)
try await priceAlertService.addPriceAlert(assetId: asset.id.identifier)
}
}
}

0 comments on commit 67418b5

Please sign in to comment.