Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ABW-3432] Sort Fee Payer accounts as in Home #1175

Merged
merged 2 commits into from
Jun 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading