Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(explore-dash): sorting options for All category #638

Merged
merged 5 commits into from
Jan 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 24 additions & 24 deletions DashWallet.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -10087,7 +10087,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_ENTITLEMENTS = dashwallet/dashwallet.entitlements;
CURRENT_PROJECT_VERSION = 10;
CURRENT_PROJECT_VERSION = 2;
DEVELOPMENT_TEAM = 44RJ69WHFF;
EXCLUDED_ARCHS = "";
"EXCLUDED_ARCHS[sdk=iphonesimulator*]" = "";
Expand Down Expand Up @@ -10116,7 +10116,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 8.0.0;
MARKETING_VERSION = 8.0.2;
OTHER_LDFLAGS = (
"$(inherited)",
"-ObjC",
Expand Down Expand Up @@ -10217,7 +10217,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_ENTITLEMENTS = dashwallet/dashwallet.entitlements;
CURRENT_PROJECT_VERSION = 10;
CURRENT_PROJECT_VERSION = 2;
DEVELOPMENT_TEAM = 44RJ69WHFF;
EXCLUDED_ARCHS = "";
GCC_PRECOMPILE_PREFIX_HEADER = YES;
Expand Down Expand Up @@ -10255,7 +10255,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 8.0.0;
MARKETING_VERSION = 8.0.2;
OTHER_LDFLAGS = (
"$(inherited)",
"-ObjC",
Expand Down Expand Up @@ -10423,12 +10423,12 @@
buildSettings = {
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CURRENT_PROJECT_VERSION = 10;
CURRENT_PROJECT_VERSION = 2;
DEVELOPMENT_TEAM = 44RJ69WHFF;
EXCLUDED_ARCHS = "";
IBSC_MODULE = WatchApp_Extension;
INFOPLIST_FILE = WatchApp/Info.plist;
MARKETING_VERSION = 8.0.0;
MARKETING_VERSION = 8.0.2;
PRODUCT_BUNDLE_IDENTIFIER = org.dashfoundation.dash.watchkitapp;
PRODUCT_NAME = "$(TARGET_NAME)";
SDKROOT = watchos;
Expand All @@ -10445,12 +10445,12 @@
buildSettings = {
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CURRENT_PROJECT_VERSION = 10;
CURRENT_PROJECT_VERSION = 2;
DEVELOPMENT_TEAM = 44RJ69WHFF;
EXCLUDED_ARCHS = "";
IBSC_MODULE = WatchApp_Extension;
INFOPLIST_FILE = WatchApp/Info.plist;
MARKETING_VERSION = 8.0.0;
MARKETING_VERSION = 8.0.2;
PRODUCT_BUNDLE_IDENTIFIER = org.dashfoundation.dash.watchkitapp;
PRODUCT_NAME = "$(TARGET_NAME)";
SDKROOT = watchos;
Expand All @@ -10465,7 +10465,7 @@
isa = XCBuildConfiguration;
baseConfigurationReference = C98AA93FF5283EC6405BCE4B /* Pods-WatchApp Extension.debug.xcconfig */;
buildSettings = {
CURRENT_PROJECT_VERSION = 1;
CURRENT_PROJECT_VERSION = 2;
DEVELOPMENT_TEAM = 44RJ69WHFF;
ENABLE_BITCODE = NO;
EXCLUDED_ARCHS = "";
Expand All @@ -10475,7 +10475,7 @@
"@executable_path/Frameworks",
"@executable_path/../../Frameworks",
);
MARKETING_VERSION = 8.0.0;
MARKETING_VERSION = 8.0.2;
PRODUCT_BUNDLE_IDENTIFIER = org.dashfoundation.dash.watchkitapp.watchkitextension;
PRODUCT_NAME = "${TARGET_NAME}";
SDKROOT = watchos;
Expand All @@ -10492,7 +10492,7 @@
isa = XCBuildConfiguration;
baseConfigurationReference = CE02413EF0C60B1D1EDE6457 /* Pods-WatchApp Extension.release.xcconfig */;
buildSettings = {
CURRENT_PROJECT_VERSION = 1;
CURRENT_PROJECT_VERSION = 2;
DEVELOPMENT_TEAM = 44RJ69WHFF;
ENABLE_BITCODE = NO;
EXCLUDED_ARCHS = "";
Expand All @@ -10502,7 +10502,7 @@
"@executable_path/Frameworks",
"@executable_path/../../Frameworks",
);
MARKETING_VERSION = 8.0.0;
MARKETING_VERSION = 8.0.2;
PRODUCT_BUNDLE_IDENTIFIER = org.dashfoundation.dash.watchkitapp.watchkitextension;
PRODUCT_NAME = "${TARGET_NAME}";
SDKROOT = watchos;
Expand Down Expand Up @@ -11204,7 +11204,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_ENTITLEMENTS = dashwallet/dashwallet.entitlements;
CURRENT_PROJECT_VERSION = 10;
CURRENT_PROJECT_VERSION = 2;
DEVELOPMENT_TEAM = 44RJ69WHFF;
EXCLUDED_ARCHS = "";
GCC_PRECOMPILE_PREFIX_HEADER = YES;
Expand Down Expand Up @@ -11242,7 +11242,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 8.0.0;
MARKETING_VERSION = 8.0.2;
OTHER_LDFLAGS = (
"$(inherited)",
"-ObjC",
Expand Down Expand Up @@ -11405,12 +11405,12 @@
buildSettings = {
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CURRENT_PROJECT_VERSION = 1;
CURRENT_PROJECT_VERSION = 2;
DEVELOPMENT_TEAM = 44RJ69WHFF;
EXCLUDED_ARCHS = "";
IBSC_MODULE = WatchApp_Extension;
INFOPLIST_FILE = WatchApp/Info.plist;
MARKETING_VERSION = 8.0.0;
MARKETING_VERSION = 8.0.2;
PRODUCT_BUNDLE_IDENTIFIER = org.dashfoundation.dash.watchkitapp;
PRODUCT_NAME = "$(TARGET_NAME)";
SDKROOT = watchos;
Expand All @@ -11425,7 +11425,7 @@
isa = XCBuildConfiguration;
baseConfigurationReference = 556B5EBEBAEA571D74FF69A3 /* Pods-WatchApp Extension.testflight.xcconfig */;
buildSettings = {
CURRENT_PROJECT_VERSION = 1;
CURRENT_PROJECT_VERSION = 2;
DEVELOPMENT_TEAM = 44RJ69WHFF;
ENABLE_BITCODE = NO;
EXCLUDED_ARCHS = "";
Expand All @@ -11435,7 +11435,7 @@
"@executable_path/Frameworks",
"@executable_path/../../Frameworks",
);
MARKETING_VERSION = 8.0.0;
MARKETING_VERSION = 8.0.2;
PRODUCT_BUNDLE_IDENTIFIER = org.dashfoundation.dash.watchkitapp.watchkitextension;
PRODUCT_NAME = "${TARGET_NAME}";
SDKROOT = watchos;
Expand Down Expand Up @@ -11524,7 +11524,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_ENTITLEMENTS = dashwallet/dashwallet.entitlements;
CURRENT_PROJECT_VERSION = 10;
CURRENT_PROJECT_VERSION = 2;
DEVELOPMENT_TEAM = 44RJ69WHFF;
EXCLUDED_ARCHS = "";
GCC_PRECOMPILE_PREFIX_HEADER = YES;
Expand Down Expand Up @@ -11552,7 +11552,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 8.0.0;
MARKETING_VERSION = 8.0.2;
OTHER_LDFLAGS = (
"$(inherited)",
"-ObjC",
Expand Down Expand Up @@ -11713,12 +11713,12 @@
buildSettings = {
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CURRENT_PROJECT_VERSION = 1;
CURRENT_PROJECT_VERSION = 2;
DEVELOPMENT_TEAM = 44RJ69WHFF;
EXCLUDED_ARCHS = "";
IBSC_MODULE = WatchApp_Extension;
INFOPLIST_FILE = WatchApp/Info.plist;
MARKETING_VERSION = 8.0.0;
MARKETING_VERSION = 8.0.2;
PRODUCT_BUNDLE_IDENTIFIER = org.dashfoundation.dash.watchkitapp;
PRODUCT_NAME = "$(TARGET_NAME)";
SDKROOT = watchos;
Expand All @@ -11733,7 +11733,7 @@
isa = XCBuildConfiguration;
baseConfigurationReference = 29B232FD70BA2EDF87F86A56 /* Pods-WatchApp Extension.testnet.xcconfig */;
buildSettings = {
CURRENT_PROJECT_VERSION = 1;
CURRENT_PROJECT_VERSION = 2;
DEVELOPMENT_TEAM = 44RJ69WHFF;
ENABLE_BITCODE = NO;
EXCLUDED_ARCHS = "";
Expand All @@ -11743,7 +11743,7 @@
"@executable_path/Frameworks",
"@executable_path/../../Frameworks",
);
MARKETING_VERSION = 8.0.0;
MARKETING_VERSION = 8.0.2;
PRODUCT_BUNDLE_IDENTIFIER = org.dashfoundation.dash.watchkitapp.watchkitextension;
PRODUCT_NAME = "${TARGET_NAME}";
SDKROOT = watchos;
Expand Down
22 changes: 9 additions & 13 deletions DashWallet/Sources/Models/Explore Dash/ExploreDash.swift
Original file line number Diff line number Diff line change
Expand Up @@ -151,26 +151,23 @@ public class ExploreDash {

extension ExploreDash {
func onlineMerchants(query: String?, onlineOnly: Bool, paymentMethods: [ExplorePointOfUse.Merchant.PaymentMethod]?,
userPoint: CLLocationCoordinate2D?, sortDirection: PointOfUseListFilters.SortDirection?, offset: Int = 0,
userPoint: CLLocationCoordinate2D?, offset: Int = 0,
completion: @escaping (Swift.Result<PaginationResult<ExplorePointOfUse>, Error>) -> Void) {
merchantDAO.onlineMerchants(query: query, onlineOnly: onlineOnly, userPoint: userPoint, paymentMethods: paymentMethods,
sortDirection: sortDirection, offset: offset, completion: completion)
merchantDAO.onlineMerchants(query: query, onlineOnly: onlineOnly, userPoint: userPoint, paymentMethods: paymentMethods, offset: offset, completion: completion)
}

func nearbyMerchants(by query: String?, in bounds: ExploreMapBounds?, userPoint: CLLocationCoordinate2D?,
paymentMethods: [ExplorePointOfUse.Merchant.PaymentMethod]?, sortBy: PointOfUseListFilters.SortBy?,
sortDirection: PointOfUseListFilters.SortDirection?, territory: Territory?, offset: Int = 0,
paymentMethods: [ExplorePointOfUse.Merchant.PaymentMethod]?, sortBy: PointOfUseListFilters.SortBy?, territory: Territory?, offset: Int = 0,
completion: @escaping (Swift.Result<PaginationResult<ExplorePointOfUse>, Error>) -> Void) {
merchantDAO.nearbyMerchants(by: query, in: bounds, userPoint: userPoint, paymentMethods: paymentMethods, sortBy: sortBy,
sortDirection: sortDirection, territory: territory, offset: offset, completion: completion)
merchantDAO.nearbyMerchants(by: query, in: bounds, userPoint: userPoint, paymentMethods: paymentMethods, sortBy: sortBy, territory: territory, offset: offset, completion: completion)
}

func allMerchants(by query: String?, in bounds: ExploreMapBounds?, userPoint: CLLocationCoordinate2D?,
paymentMethods: [ExplorePointOfUse.Merchant.PaymentMethod]?, sortBy: PointOfUseListFilters.SortBy?,
sortDirection: PointOfUseListFilters.SortDirection?, territory: Territory?, offset: Int = 0,
paymentMethods: [ExplorePointOfUse.Merchant.PaymentMethod]?,
sortBy: PointOfUseListFilters.SortBy?,
territory: Territory?, offset: Int = 0,
completion: @escaping (Swift.Result<PaginationResult<ExplorePointOfUse>, Error>) -> Void) {
merchantDAO.allMerchants(by: query, in: bounds, userPoint: userPoint, paymentMethods: paymentMethods, sortBy: sortBy,
sortDirection: sortDirection, territory: territory, offset: offset, completion: completion)
merchantDAO.allMerchants(by: query, in: bounds, userPoint: userPoint, paymentMethods: paymentMethods, sortBy: sortBy, territory: territory, offset: offset, completion: completion)
}

func allLocations(for merchantId: Int64, in bounds: ExploreMapBounds?, userPoint: CLLocationCoordinate2D?,
Expand All @@ -196,8 +193,7 @@ extension ExploreDash {
.types: types,
.bounds: bounds,
.userLocation: userPoint,
.territory: filters?.territory,
.sortDirection: filters?.sortNameDirection,
.territory: filters?.territory
]

atmDAO.items(filters: filters, offset: offset, completion: completion)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,7 @@ class AtmDAO: PointOfUseDAO {
.filter(queryFilter)


if let sortDirection = filters[.sortDirection] as? PointOfUseListFilters.SortDirection {
query = query.order(sortDirection == .ascending ? name.collate(.nocase).asc : name.collate(.nocase).desc)
} else if let userLocation = filters[.userLocation] as? CLLocationCoordinate2D {
if let userLocation = filters[.userLocation] as? CLLocationCoordinate2D {
let anchorLatitude = userLocation.latitude
let anchorLongitude = userLocation.longitude

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ class MerchantDAO: PointOfUseDAO {
types: [ExplorePointOfUse.Merchant.`Type`],
paymentMethods: [ExplorePointOfUse.Merchant.PaymentMethod]?,
sortBy: PointOfUseListFilters.SortBy?,
sortDirection: PointOfUseListFilters.SortDirection?,
territory: Territory?,
offset: Int,
completion: @escaping (Swift.Result<PaginationResult<Item>, Error>) -> Void) {
Expand Down Expand Up @@ -109,7 +108,7 @@ class MerchantDAO: PointOfUseDAO {
Expression<Bool>(literal: "((latitude-\(anchorLatitude))*(latitude-\(anchorLatitude))) + ((longitude - \(anchorLongitude))*(longitude - \(anchorLongitude))) ASC")
}

let nameOrdering = sortDirection == .descending ? name.collate(.nocase).desc : name.collate(.nocase).asc
let nameOrdering = name.collate(.nocase).asc

if let sortBy, sortBy == .name {
query = query.order(nameOrdering)
Expand Down Expand Up @@ -145,29 +144,23 @@ class MerchantDAO: PointOfUseDAO {

extension MerchantDAO {
func onlineMerchants(query: String?, onlineOnly: Bool, userPoint: CLLocationCoordinate2D?,
paymentMethods: [ExplorePointOfUse.Merchant.PaymentMethod]?,
sortDirection: PointOfUseListFilters.SortDirection?, offset: Int = 0,
paymentMethods: [ExplorePointOfUse.Merchant.PaymentMethod]?, offset: Int = 0,
completion: @escaping (Swift.Result<PaginationResult<ExplorePointOfUse>, Error>) -> Void) {
items(query: query, bounds: nil, userLocation: userPoint, types: [.online, .onlineAndPhysical],
paymentMethods: paymentMethods, sortBy: nil, sortDirection: sortDirection, territory: nil, offset: offset,
completion: completion)
paymentMethods: paymentMethods, sortBy: nil, territory: nil, offset: offset, completion: completion)
}

func nearbyMerchants(by query: String?, in bounds: ExploreMapBounds?, userPoint: CLLocationCoordinate2D?,
paymentMethods: [ExplorePointOfUse.Merchant.PaymentMethod]?, sortBy: PointOfUseListFilters.SortBy?,
sortDirection: PointOfUseListFilters.SortDirection?, territory: Territory?, offset: Int = 0,
paymentMethods: [ExplorePointOfUse.Merchant.PaymentMethod]?, sortBy: PointOfUseListFilters.SortBy?, territory: Territory?, offset: Int = 0,
completion: @escaping (Swift.Result<PaginationResult<ExplorePointOfUse>, Error>) -> Void) {
items(query: query, bounds: bounds, userLocation: userPoint, types: [.physical, .onlineAndPhysical],
paymentMethods: paymentMethods, sortBy: sortBy, sortDirection: sortDirection, territory: territory, offset: offset,
completion: completion)
paymentMethods: paymentMethods, sortBy: sortBy, territory: territory, offset: offset, completion: completion)
}

func allMerchants(by query: String?, in bounds: ExploreMapBounds?, userPoint: CLLocationCoordinate2D?,
paymentMethods: [ExplorePointOfUse.Merchant.PaymentMethod]?, sortBy: PointOfUseListFilters.SortBy?,
sortDirection: PointOfUseListFilters.SortDirection?, territory: Territory?, offset: Int = 0,
paymentMethods: [ExplorePointOfUse.Merchant.PaymentMethod]?, sortBy: PointOfUseListFilters.SortBy?, territory: Territory?, offset: Int = 0,
completion: @escaping (Swift.Result<PaginationResult<ExplorePointOfUse>, Error>) -> Void) {
items(query: query, bounds: bounds, userLocation: userPoint, types: [.online, .onlineAndPhysical, .physical],
paymentMethods: paymentMethods, sortBy: sortBy, sortDirection: sortDirection, territory: territory, offset: offset,
items(query: query, bounds: bounds, userLocation: userPoint, types: [.online, .onlineAndPhysical, .physical], paymentMethods: paymentMethods, sortBy: sortBy, territory: territory, offset: offset,
completion: completion)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ enum AtmListSegmnets: Int {

var pointOfUseListSegment: PointOfUseListSegment {
var defaultFilters = PointOfUseListFilters()
defaultFilters.sortNameDirection = .ascending
defaultFilters.radius = .twenty

return .init(tag: rawValue, title: title, showMap: true, showLocationServiceSettings: false, showReversedLocation: true,
Expand Down Expand Up @@ -68,7 +67,7 @@ extension AtmListSegmnets {
}

var filterGroups: [PointOfUseListFiltersGroup] {
[.sortByName, .territory, .radius, .locationService]
[.sortByDistanceOrName, .territory, .radius, .locationService]
}

var territories: TerritoryDataSource {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,9 @@ extension ExplorePointOfUseListViewController {
extension ExplorePointOfUseListViewController {
private func showFilters() {
let vc = PointOfUseListFiltersViewController.controller()
vc.filtersToUse = currentSegment.filterGroups
vc.filtersToUse = currentSegment.filterGroups.filter { filter in
DWLocationManager.shared.currentLocation != nil || (filter != .sortByDistanceOrName && filter != .radius)
}
vc.territoriesDataSource = currentSegment.territoriesDataSource
vc.delegate = self
vc.defaultFilters = model.initialFilters
Expand Down
Loading
Loading