From 18cd571573bdbf7c14a248cc82bf9a89491b823c Mon Sep 17 00:00:00 2001 From: dankito Date: Sun, 20 Sep 2020 16:18:06 +0200 Subject: [PATCH] Sorting now transactions only when necessary and not on each view update --- .../ui/dialogs/AccountTransactionsDialog.swift | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ui/BankingiOSApp/BankingiOSApp/ui/dialogs/AccountTransactionsDialog.swift b/ui/BankingiOSApp/BankingiOSApp/ui/dialogs/AccountTransactionsDialog.swift index 41756114..87135f4f 100644 --- a/ui/BankingiOSApp/BankingiOSApp/ui/dialogs/AccountTransactionsDialog.swift +++ b/ui/BankingiOSApp/BankingiOSApp/ui/dialogs/AccountTransactionsDialog.swift @@ -69,7 +69,7 @@ struct AccountTransactionsDialog: View { self.title = title self.allTransactions = transactions - self._filteredTransactions = State(initialValue: transactions) + self._filteredTransactions = State(initialValue: transactions.sorted { $0.valueDate.date > $1.valueDate.date }) self._balanceOfAllTransactions = State(initialValue: balance) self._balanceOfFilteredTransactions = State(initialValue: balance) @@ -99,7 +99,7 @@ struct AccountTransactionsDialog: View { } Section { - ForEach(filteredTransactions.sorted(by: { $0.valueDate.date > $1.valueDate.date } ), id: \.technicalId) { transaction in + ForEach(filteredTransactions, id: \.technicalId) { transaction in AccountTransactionListItem(transaction, self.areMoreThanOneBanksTransactionsDisplayed) } } @@ -199,7 +199,7 @@ struct AccountTransactionsDialog: View { } private func filterTransactions(_ query: String) { - self.filteredTransactions = presenter.searchSelectedAccountTransactions(query: query) + self.filteredTransactions = presenter.searchSelectedAccountTransactions(query: query).sorted { $0.valueDate.date > $1.valueDate.date } self.balanceOfFilteredTransactions = query.isBlank ? balanceOfAllTransactions : filteredTransactions.sumAmounts() }