From aaf9ec7176fdba54cb25cbf61d5d20feff47d9c8 Mon Sep 17 00:00:00 2001 From: Simon McLoughlin Date: Fri, 16 Feb 2024 11:54:49 +0000 Subject: [PATCH] - bump library to get 3route abstraction fix - make sure no uniqueness collisions with other pending items - sort based on counter so newest is always top --- .../xcshareddata/swiftpm/Package.resolved | 2 +- Kukai Mobile/Modules/Activity/ActivityViewModel.swift | 2 +- Kukai Mobile/Services/ActivityService.swift | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Kukai Mobile.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved b/Kukai Mobile.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved index aef8f6b2..dadb2554 100644 --- a/Kukai Mobile.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved +++ b/Kukai Mobile.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved @@ -69,7 +69,7 @@ "location" : "https://github.com/kukai-wallet/kukai-core-swift", "state" : { "branch" : "develop", - "revision" : "da94dc790fce0ce2228bb7930303f4670bd9cef0" + "revision" : "4e775b2632f44b24fee55de769aa438e0e5eb6d5" } }, { diff --git a/Kukai Mobile/Modules/Activity/ActivityViewModel.swift b/Kukai Mobile/Modules/Activity/ActivityViewModel.swift index 206112bc..8bdb3779 100644 --- a/Kukai Mobile/Modules/Activity/ActivityViewModel.swift +++ b/Kukai Mobile/Modules/Activity/ActivityViewModel.swift @@ -138,7 +138,7 @@ class ActivityViewModel: ViewModel, UITableViewDiffableDataSourceHandler { var full = DependencyManager.shared.activityService.pendingTransactionGroups.filter({ $0.transactions.first?.sender.address == currentAddress }) full.append(contentsOf: DependencyManager.shared.activityService.transactionGroups) - full.sort(by: { ($0.transactions.first?.id) ?? 0 > ($1.transactions.first?.id) ?? 0 }) + full.sort(by: { ($0.transactions.first?.counter) ?? 0 > ($1.transactions.first?.counter) ?? 0 }) self.groups = full self.loadGroups(animate: animate) diff --git a/Kukai Mobile/Services/ActivityService.swift b/Kukai Mobile/Services/ActivityService.swift index de075d35..65a1e2f5 100644 --- a/Kukai Mobile/Services/ActivityService.swift +++ b/Kukai Mobile/Services/ActivityService.swift @@ -109,7 +109,7 @@ public class ActivityService { public func addPending(opHash: String, type: TzKTTransaction.TransactionType, counter: Decimal, fromWallet: WalletMetadata, destinationAddress: String, destinationAlias: String?, xtzAmount: TokenAmount, parameters: [String: String]?, primaryToken: Token?) -> Bool { let destination = TzKTAddress(alias: destinationAlias, address: destinationAddress) - let previousId = transactionGroups.first?.transactions.first?.id ?? 0 + let previousId = pendingTransactionGroups.count == 0 ? (transactionGroups.first?.transactions.first?.id ?? 0) : (pendingTransactionGroups.first?.id ?? 0) var transaction = TzKTTransaction.placeholder(withStatus: .unconfirmed, id: previousId + 1, opHash: opHash, type: type, counter: counter, fromWallet: fromWallet, destination: destination, xtzAmount: xtzAmount, parameters: parameters, primaryToken: primaryToken) transaction.processAdditionalData(withCurrentWalletAddress: fromWallet.address) @@ -126,7 +126,7 @@ public class ActivityService { } public func addPendingBatch(opHash: String, counter: Decimal, fromWallet: WalletMetadata, batchInfo: [PendingBatchInfo]) -> Bool { - var previousId = transactionGroups.first?.transactions.first?.id ?? 0 + var previousId = pendingTransactionGroups.count == 0 ? (transactionGroups.first?.transactions.first?.id ?? 0) : (pendingTransactionGroups.first?.id ?? 0) var transactions: [TzKTTransaction] = [] for info in batchInfo { @@ -150,7 +150,7 @@ public class ActivityService { } public func addPending(opHash: String, type: TzKTTransaction.TransactionType, counter: Decimal, fromWallet: WalletMetadata, newDelegate: TzKTAddress?) -> Bool { - let previousId = transactionGroups.first?.transactions.first?.id ?? 0 + let previousId = pendingTransactionGroups.count == 0 ? (transactionGroups.first?.transactions.first?.id ?? 0) : (pendingTransactionGroups.first?.id ?? 0) let transaction = TzKTTransaction.placeholder(withStatus: .unconfirmed, id: previousId + 1, opHash: opHash, type: type, counter: counter, fromWallet: fromWallet, newDelegate: newDelegate) if let group = TzKTTransactionGroup(withTransactions: [transaction], currentWalletAddress: fromWallet.address) {