From 6b6119afbd208a1ffa2cbe138bc0bb72880975c8 Mon Sep 17 00:00:00 2001 From: Artur Guseinov Date: Tue, 28 Nov 2023 15:01:14 +0300 Subject: [PATCH] Curate explorer listings --- .../WalletApp/BusinessLayer/ListingsSertice/Listings.swift | 3 +++ .../WalletApp/BusinessLayer/ListingsSertice/ListingsAPI.swift | 2 +- .../Wallet/Notifications/Models/ListingViewModel.swift | 4 ++++ .../Wallet/Notifications/NotificationsPresenter.swift | 3 ++- 4 files changed, 10 insertions(+), 2 deletions(-) diff --git a/Example/WalletApp/BusinessLayer/ListingsSertice/Listings.swift b/Example/WalletApp/BusinessLayer/ListingsSertice/Listings.swift index 4ab2673c9..276c56072 100644 --- a/Example/WalletApp/BusinessLayer/ListingsSertice/Listings.swift +++ b/Example/WalletApp/BusinessLayer/ListingsSertice/Listings.swift @@ -17,4 +17,7 @@ struct Listing: Codable { let homepage: String? let image_url: ImageURL? let dapp_url: String + let order: Int? + let is_verified: Bool + let is_featured: Bool } diff --git a/Example/WalletApp/BusinessLayer/ListingsSertice/ListingsAPI.swift b/Example/WalletApp/BusinessLayer/ListingsSertice/ListingsAPI.swift index 8e3700db7..c121e1e38 100644 --- a/Example/WalletApp/BusinessLayer/ListingsSertice/ListingsAPI.swift +++ b/Example/WalletApp/BusinessLayer/ListingsSertice/ListingsAPI.swift @@ -16,7 +16,7 @@ enum ListingsAPI: HTTPService { } var queryParameters: [String : String]? { - return ["projectId": InputConfig.projectId, "entries": "100", "is_verified": "false"] + return ["projectId": InputConfig.projectId, "entries": "100"] } var additionalHeaderFields: [String : String]? { diff --git a/Example/WalletApp/PresentationLayer/Wallet/Notifications/Models/ListingViewModel.swift b/Example/WalletApp/PresentationLayer/Wallet/Notifications/Models/ListingViewModel.swift index 08286926d..f74194ff0 100644 --- a/Example/WalletApp/PresentationLayer/Wallet/Notifications/Models/ListingViewModel.swift +++ b/Example/WalletApp/PresentationLayer/Wallet/Notifications/Models/ListingViewModel.swift @@ -24,4 +24,8 @@ struct ListingViewModel: Identifiable { let url = listing.dapp_url return URL(string: url)?.host } + + var order: Int { + return listing.order ?? 10000 + } } diff --git a/Example/WalletApp/PresentationLayer/Wallet/Notifications/NotificationsPresenter.swift b/Example/WalletApp/PresentationLayer/Wallet/Notifications/NotificationsPresenter.swift index 91a573857..6bf09eda2 100644 --- a/Example/WalletApp/PresentationLayer/Wallet/Notifications/NotificationsPresenter.swift +++ b/Example/WalletApp/PresentationLayer/Wallet/Notifications/NotificationsPresenter.swift @@ -23,8 +23,9 @@ final class NotificationsPresenter: ObservableObject { var listingViewModels: [ListingViewModel] { return listings .map { ListingViewModel(listing: $0) } - .sorted(by: + .sorted(by: { subscription(forListing: $0) != nil && subscription(forListing: $1) == nil }, + { $0.order < $1.order }, { $0.title < $1.title } ) }