Skip to content

Commit

Permalink
Don't always reset the portfolio
Browse files Browse the repository at this point in the history
  • Loading branch information
kugel3 committed Oct 9, 2023
1 parent eee33cb commit d8c4c37
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,10 @@ extension AccountList {
public func reduce(into state: inout State, viewAction: ViewAction) -> Effect<Action> {
switch viewAction {
case .task:

let accountAddress = state.account.address
state.portfolio = .loading
if state.portfolio.wrappedValue == nil {
state.portfolio = .loading
}

checkIfCallActionIsNeeded(state: &state)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,7 @@ public struct DevAccountPreferences: Sendable, FeatureReducer {

case let .callDone(controlStateKeyPath, changeTo):
if controlStateKeyPath == \State.faucetButtonState {
// NB: This call to update might be superfluous, since after any transaction we fetch all accounts
return updateAccountPortfolio(state).concatenate(with: loadIsAllowedToUseFaucet(&state))
} else {
state[keyPath: controlStateKeyPath] = changeTo
Expand Down
4 changes: 4 additions & 0 deletions Sources/Features/HomeFeature/Coordinator/Home.swift
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,10 @@ public struct Home: Sendable, FeatureReducer {
public func reduce(into state: inout State, internalAction: InternalAction) -> Effect<Action> {
switch internalAction {
case let .accountsLoadedResult(.success(accounts)):
guard accounts.elements != state.accounts.elements else {
return .none
}

state.accountList = .init(accounts: accounts)
let accountAddresses = state.accounts.map(\.address)
return .run { _ in
Expand Down

0 comments on commit d8c4c37

Please sign in to comment.