From 1c3193520edf9a43935c93d2f24bbfa6dc316be7 Mon Sep 17 00:00:00 2001 From: Hwee-Boon Yar Date: Sat, 13 Apr 2019 23:46:11 +0800 Subject: [PATCH] Fix: Order of transactions in tab within each day is displayed in reverse --- AlphaWallet/Tokens/Types/TransactionCollection.swift | 3 +-- .../Transactions/ViewModels/TransactionsViewModel.swift | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/AlphaWallet/Tokens/Types/TransactionCollection.swift b/AlphaWallet/Tokens/Types/TransactionCollection.swift index 2e137ab6fe..ff9646cf24 100644 --- a/AlphaWallet/Tokens/Types/TransactionCollection.swift +++ b/AlphaWallet/Tokens/Types/TransactionCollection.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 } } diff --git a/AlphaWallet/Transactions/ViewModels/TransactionsViewModel.swift b/AlphaWallet/Transactions/ViewModels/TransactionsViewModel.swift index d8d4f3a565..0f1d99a822 100644 --- a/AlphaWallet/Transactions/ViewModels/TransactionsViewModel.swift +++ b/AlphaWallet/Transactions/ViewModels/TransactionsViewModel.swift @@ -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)! }