Merge pull request #1181 from AlphaWallet/fix-order-transactions-tab-reversed

Fix: Order of transactions in tab within each day is displayed in reverse
pull/1184/head
James Sangalli 6 years ago committed by GitHub
commit b3058f3d97
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 3
      AlphaWallet/Tokens/Types/TransactionCollection.swift
  2. 2
      AlphaWallet/Transactions/ViewModels/TransactionsViewModel.swift

@ -20,11 +20,10 @@ class TransactionCollection {
var objects: [Transaction] {
var transactions = [Transaction]()
//Concatenate arrays of hundreds/thousands of elements and then sort them. Room for speed improvement, but it seems good enough so far. It'll be much more efficient if we do a single read from Realm directly and sort with Realm
//Concatenate arrays of hundreds/thousands of elements. Room for speed improvement, but it seems good enough so far. It'll be much more efficient if we do a single read from Realm directly
for each in transactionsStorages {
transactions.append(contentsOf: Array(each.objects))
}
transactions.sort { $0.date < $1.date }
return transactions
}
}

@ -20,7 +20,7 @@ struct TransactionsViewModel {
newItems[date] = currentItems
}
//TODO. IMPROVE perfomance
let tuple = newItems.map { (key, values) in return (date: key, transactions: values) }
let tuple = newItems.map { (key, values) in return (date: key, transactions: values.sorted { $0.date > $1.date }) }
items = tuple.sorted { (object1, object2) -> Bool in
return formatter.date(from: object1.date)! > formatter.date(from: object2.date)!
}

Loading…
Cancel
Save