[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[taler-taler-ios] 24/32: static func <
From: |
gnunet |
Subject: |
[taler-taler-ios] 24/32: static func < |
Date: |
Sat, 10 Feb 2024 15:04:50 +0100 |
This is an automated email from the git hooks/post-receive script.
marc-stibane pushed a commit to branch master
in repository taler-ios.
commit 17e0e92b012c3fe08c6bb58b3f3044fe0df93d58
Author: Marc Stibane <marc@taler.net>
AuthorDate: Thu Feb 8 17:46:38 2024 +0100
static func <
---
TalerWallet1/Backend/WalletBackendRequest.swift | 24 ++++++++++++++++++++++++
TalerWallet1/Model/Model+Exchange.swift | 9 +++++++++
2 files changed, 33 insertions(+)
diff --git a/TalerWallet1/Backend/WalletBackendRequest.swift
b/TalerWallet1/Backend/WalletBackendRequest.swift
index 6a5ef20..19bee0b 100644
--- a/TalerWallet1/Backend/WalletBackendRequest.swift
+++ b/TalerWallet1/Backend/WalletBackendRequest.swift
@@ -34,6 +34,30 @@ struct ScopeInfo: Codable, Hashable {
var url: String? // only for "exchange"
var currency: String // 3-char ISO 4217 code for global currency.
Regional MUST be >= 4 letters
+ public static func < (lhs: ScopeInfo, rhs: ScopeInfo) -> Bool {
+ if lhs.type == .global {
+ if rhs.type == .global { // both global ==> alphabetic
currency
+ return lhs.currency < rhs.currency
+ }
+ return true // global comes first
+ }
+ if rhs.type == .global {
+ return false // global comes first
+ }
+ if lhs.currency == rhs.currency {
+ if let lhsBaseURL = lhs.url {
+ if let rhsBaseURL = rhs.url {
+ return lhsBaseURL < rhsBaseURL
+ }
+ return true
+ }
+ if let rhsBaseURL = rhs.url {
+ return false
+ }
+ // fall thru
+ }
+ return lhs.currency < rhs.currency
+ }
public static func == (lhs: ScopeInfo, rhs: ScopeInfo) -> Bool {
if let lhsBaseURL = lhs.url {
if let rhsBaseURL = rhs.url {
diff --git a/TalerWallet1/Model/Model+Exchange.swift
b/TalerWallet1/Model/Model+Exchange.swift
index 5b362f0..6de9b6a 100644
--- a/TalerWallet1/Model/Model+Exchange.swift
+++ b/TalerWallet1/Model/Model+Exchange.swift
@@ -29,6 +29,15 @@ enum ExchangeUpdateStatus: String, Codable {
// MARK: -
/// The result from wallet-core's ListExchanges
struct Exchange: Codable, Hashable, Identifiable {
+ static func < (lhs: Exchange, rhs: Exchange) -> Bool {
+ if let leftScope = lhs.scopeInfo {
+ if let rightScope = rhs.scopeInfo {
+ return leftScope < rightScope
+ }
+ return true // scopeInfo comes first
+ }
+ return false
+ }
static func == (lhs: Exchange, rhs: Exchange) -> Bool {
return lhs.exchangeBaseUrl == rhs.exchangeBaseUrl
&& lhs.tosStatus == rhs.tosStatus
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
- [taler-taler-ios] 32/32: remove reward, (continued)
- [taler-taler-ios] 32/32: remove reward, gnunet, 2024/02/10
- [taler-taler-ios] 31/32: Wording, gnunet, 2024/02/10
- [taler-taler-ios] 12/32: devExperiment Refresh, gnunet, 2024/02/10
- [taler-taler-ios] 11/32: Identifiable, gnunet, 2024/02/10
- [taler-taler-ios] 28/32: RotatingTaler while waiting for tx to finish, gnunet, 2024/02/10
- [taler-taler-ios] 23/32: TransactionDetailV, gnunet, 2024/02/10
- [taler-taler-ios] 19/32: Show merchant in payment details, gnunet, 2024/02/10
- [taler-taler-ios] 15/32: githash 7 chars, gnunet, 2024/02/10
- [taler-taler-ios] 22/32: CallStack, gnunet, 2024/02/10
- [taler-taler-ios] 10/32: ScrollVStack, gnunet, 2024/02/10
- [taler-taler-ios] 24/32: static func <,
gnunet <=
- [taler-taler-ios] 29/32: cleanup, gnunet, 2024/02/10
- [taler-taler-ios] 25/32: use ScopeInfo, gnunet, 2024/02/10