Skip to content

Commit

Permalink
[ABW-3432] Sort Fee Payer accounts as in Home (#1175)
Browse files Browse the repository at this point in the history
  • Loading branch information
matiasbzurovski committed Jun 14, 2024
1 parent 8cd380f commit b082c97
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -93,16 +93,15 @@ extension TransactionClient {
func getAllFeePayerCandidates(refreshingBalances: Bool) async throws -> NonEmpty<IdentifiedArrayOf<FeePayerCandidate>> {
let networkID = await gatewaysClient.getCurrentNetworkID()
let allAccounts = try await accountsClient.getAccountsOnNetwork(networkID)
let entities = try await onLedgerEntitiesClient.getAccounts(allAccounts.map(\.address), cachingStrategy: .forceUpdate)

let allFeePayerCandidates = try await onLedgerEntitiesClient.getAccounts(allAccounts.map(\.address), cachingStrategy: .forceUpdate).compactMap { portfolio -> FeePayerCandidate? in
guard
let account = allAccounts.first(where: { account in account.address == portfolio.address })
else {
let allFeePayerCandidates = allAccounts.compactMap { account -> FeePayerCandidate? in
guard let entity = entities.first(where: { $0.address == account.address }) else {
assertionFailure("Failed to find account or no balance, this should never happen.")
return nil
}

guard let xrdBalance = portfolio.fungibleResources.xrdResource?.amount else {
guard let xrdBalance = entity.fungibleResources.xrdResource?.amount else {
return nil
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,27 +56,33 @@ extension SelectFeePayer {
.padding(.horizontal, .large3)
.padding(.bottom, .small1)

ScrollView {
loadable(viewStore.feePayerCandidates) {
ProgressView()
} successContent: { candidates in
VStack(spacing: .small1) {
Selection(
viewStore.binding(
get: \.selectedPayer,
send: { .selectedPayer($0) }
),
from: candidates
) { item in
SelectAccountToPayForFeeRow.View(
viewState: .init(candidate: item.value),
isSelected: item.isSelected,
action: item.action
)
ScrollViewReader { proxy in
ScrollView {
loadable(viewStore.feePayerCandidates) {
ProgressView()
} successContent: { candidates in
VStack(spacing: .small1) {
Selection(
viewStore.binding(
get: \.selectedPayer,
send: { .selectedPayer($0) }
),
from: candidates
) { item in
SelectAccountToPayForFeeRow.View(
viewState: .init(candidate: item.value),
isSelected: item.isSelected,
action: item.action
)
.id(item.value.id)
}
}
.padding(.horizontal, .medium1)
.padding(.bottom, .medium2)
.onFirstAppear {
proxy.scrollTo(viewStore.selectedPayer?.id, anchor: .center)
}
}
.padding(.horizontal, .medium1)
.padding(.bottom, .medium2)
}
}
.refreshable { @MainActor in
Expand Down

0 comments on commit b082c97

Please sign in to comment.