From e8aee07b3412ff093bce786a12ba26ec115b0ba8 Mon Sep 17 00:00:00 2001 From: dankito Date: Fri, 25 Sep 2020 00:40:40 +0200 Subject: [PATCH] Fixed that BankListItem and BankAccountListItem didn't get updated on changes like balance changed or retrieved bank icon --- .../BankingiOSApp/extensions/Extensions.swift | 13 +++++++++++++ .../BankingiOSApp/ui/dialogs/AccountsDialog.swift | 3 ++- .../ui/views/listitems/BankListItem.swift | 3 ++- 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/ui/BankingiOSApp/BankingiOSApp/extensions/Extensions.swift b/ui/BankingiOSApp/BankingiOSApp/extensions/Extensions.swift index 8694e9fb..5c02601b 100644 --- a/ui/BankingiOSApp/BankingiOSApp/extensions/Extensions.swift +++ b/ui/BankingiOSApp/BankingiOSApp/extensions/Extensions.swift @@ -70,6 +70,19 @@ extension KeychainPasswordItem { } +extension IBankData { + + var randomId: UUID { UUID() } + +} + +extension IBankAccount { + + var randomId: UUID { UUID() } + +} + + extension BankData : Identifiable { public var id: String { technicalId } diff --git a/ui/BankingiOSApp/BankingiOSApp/ui/dialogs/AccountsDialog.swift b/ui/BankingiOSApp/BankingiOSApp/ui/dialogs/AccountsDialog.swift index 711cd436..262be95b 100644 --- a/ui/BankingiOSApp/BankingiOSApp/ui/dialogs/AccountsDialog.swift +++ b/ui/BankingiOSApp/BankingiOSApp/ui/dialogs/AccountsDialog.swift @@ -22,7 +22,8 @@ struct AccountsDialog: View { Form { AllBanksListItem(banks: data.banks) - ForEach(data.banks.sortedByDisplayIndex(), id: \.technicalId) { bank in + // if a constant id like \.technicalId is provided, list doesn't get updated on changes like balance changed or retrieved bank icon + ForEach(data.banksSorted, id: \.randomId) { bank in BankListItem(bank: bank) } diff --git a/ui/BankingiOSApp/BankingiOSApp/ui/views/listitems/BankListItem.swift b/ui/BankingiOSApp/BankingiOSApp/ui/views/listitems/BankListItem.swift index 5ca58d8a..0a7d871e 100644 --- a/ui/BankingiOSApp/BankingiOSApp/ui/views/listitems/BankListItem.swift +++ b/ui/BankingiOSApp/BankingiOSApp/ui/views/listitems/BankListItem.swift @@ -47,7 +47,8 @@ struct BankListItem : View { } - ForEach(bank.accountsSorted, id: \.technicalId) { account in + // if a constant id like \.technicalId is provided, list doesn't get updated on changes e.g. when balance changes + ForEach(bank.accountsSorted, id: \.randomId) { account in BankAccountListItem(account: account) } .padding(.leading, Styles.AccountsIconWidth + Styles.DefaultSpaceBetweenIconAndText)