Skip to content
This repository has been archived by the owner on May 10, 2024. It is now read-only.

Commit

Permalink
Fix #8649: Improve Performance of Select Token to Send (#8654)
Browse files Browse the repository at this point in the history
* Update performance of `SelectAccountTokenStore`; build account sections for changes instead of computed property

* Fix for case where balance is 0 after being cached as non-zero does not update cache, don't lose cached balances after failed response.
  • Loading branch information
StephenHeaps authored Jan 15, 2024
1 parent 1c1920e commit d2a497f
Show file tree
Hide file tree
Showing 5 changed files with 334 additions and 419 deletions.
2 changes: 1 addition & 1 deletion Sources/BraveWallet/Crypto/BuySendSwap/SendTokenView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ struct SendTokenView: View {
didAutoShowSelectAccountToken = true
}
sendTokenStore.update()
await sendTokenStore.selectTokenStore.update()
sendTokenStore.selectTokenStore.setup()
}
.navigationViewStyle(.stack)
}
Expand Down
8 changes: 4 additions & 4 deletions Sources/BraveWallet/Crypto/SelectAccountTokenView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@ struct SelectAccountTokenView: View {

var body: some View {
List {
if store.accountSections.isEmpty {
if !store.isSetup {
// Fetching accounts & assets. Typically won't see this.
ProgressView()
.listRowBackground(Color(.secondaryBraveGroupedBackground))
} else if store.filteredAccountSections.flatMap(\.tokenBalances).isEmpty && !store.isLoadingBalances {
} else if store.accountSections.isEmpty && !store.isLoadingBalances {
Text(Strings.Wallet.selectTokenToSendNoTokens)
.font(.headline.weight(.semibold))
.foregroundColor(Color(.braveLabel))
Expand Down Expand Up @@ -80,7 +80,7 @@ struct SelectAccountTokenView: View {
if !store.isHidingZeroBalances {
return true
}
return store.filteredAccountSections.flatMap(\.tokenBalances).isEmpty
return store.accountSections.isEmpty
}

private var networkFilterButton: some View {
Expand Down Expand Up @@ -110,7 +110,7 @@ struct SelectAccountTokenView: View {
}

private var accountSections: some View {
ForEach(store.filteredAccountSections) { accountSection in
ForEach(store.accountSections) { accountSection in
Section(
content: {
if accountSection.tokenBalances.isEmpty {
Expand Down
Loading

0 comments on commit d2a497f

Please sign in to comment.