Skip to content

Commit

Permalink
done
Browse files Browse the repository at this point in the history
  • Loading branch information
kugel3 committed Mar 13, 2024
1 parent c63e0d9 commit 82c78c3
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ extension TransactionHistoryClient {
let transactionItem = try await transaction(for: item)
items.append(transactionItem)
}

if !request.parameters.backwards {
items.reverse()
}
Expand All @@ -147,11 +148,6 @@ extension TransactionHistoryClient {
resources: keyedResources,
items: items
)

// return try await .init(
// cursor: response.nextCursor,
// items: response.items.parallelMap(transaction(for:))
// )
}

return TransactionHistoryClient(
Expand Down Expand Up @@ -207,7 +203,7 @@ extension TransactionHistoryRequest {
atLedgerState: .init(timestamp: parameters.period.upperBound),
fromLedgerState: .init(timestamp: parameters.period.lowerBound),
cursor: cursor,
limitPerPage: 10,
limitPerPage: 20,
manifestResourcesFilter: manifestResourcesFilter(parameters.filters),
affectedGlobalEntitiesFilter: [account.address],
eventsFilter: eventsFilter(parameters.filters, account: account),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ public struct TransactionHistory: Sendable, FeatureReducer {
@Dependency(\.errorQueue) var errorQueue
@Dependency(\.transactionHistoryClient) var transactionHistoryClient
@Dependency(\.gatewayAPIClient) var gatewayAPIClient
@Dependency(\.openURL) var openURL

public init() {}

Expand All @@ -121,16 +122,13 @@ public struct TransactionHistory: Sendable, FeatureReducer {
public func reduce(into state: inout State, viewAction: ViewAction) -> Effect<Action> {
switch viewAction {
case .onAppear:
// return loadHistory(period: .babylonLaunch ..< .now, state: &state)
return loadHistory(
period: .init(timeIntervalSinceNow: -80 * 24 * 3600) ..< .init(timeIntervalSinceNow: -40 * 24 * 3600),
state: &state
)
return loadHistory(period: .babylonLaunch ..< .now, state: &state)

case let .selectedMonth(month):
let calendar: Calendar = .current
guard let endOfMonth = calendar.date(byAdding: .month, value: 1, to: month) else { return .none }
return loadHistory(period: .babylonLaunch ..< endOfMonth, state: &state)
let period: Range<Date> = .babylonLaunch ..< min(endOfMonth, .now)
return loadHistory(period: period, state: &state)

case .filtersTapped:
state.destination = .filters(.init(portfolio: state.portfolio, filters: state.activeFilters.map(\.id)))
Expand Down Expand Up @@ -302,12 +300,6 @@ extension Range<Date> {
var debugString: String {
"\(lowerBound.formatted(date: .abbreviated, time: .omitted)) -- \(upperBound.formatted(date: .abbreviated, time: .omitted))"
}

var clamped: Range? {
let now: Date = .now
guard lowerBound < now else { return nil }
return lowerBound ..< Swift.min(upperBound, now)
}
}

extension IdentifiedArrayOf<TransactionHistory.State.TransactionSection> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ extension TransactionHistory {

if viewStore.loading.isLoading, !viewStore.loading.parameters.backwards {
ProgressView()
.padding(.small1)
}

ForEach(viewStore.sections) { section in
Expand Down Expand Up @@ -103,7 +104,7 @@ extension TransactionHistory {
}
}
.onReadPosition(View.accountDummy) { rect in
if rect.minY > 30 {
if rect.minY > 50 {
store.send(.view(.pulledDown))
}
}
Expand Down

0 comments on commit 82c78c3

Please sign in to comment.