Skip to content

Commit

Permalink
Fix Account&Persona unhide (#1039)
Browse files Browse the repository at this point in the history
  • Loading branch information
GhenadieVP committed Mar 13, 2024
1 parent 09beb73 commit 45bbd6f
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,6 @@ public struct AccountAndPersonaHiding: Sendable, FeatureReducer {
public enum ViewAction: Hashable, Sendable {
case task
case unhideAllTapped

case confirmUnhideAllAlert(PresentationAction<ConfirmUnhideAllAlert>)

public enum ConfirmUnhideAllAlert: Hashable, Sendable {
case confirmTapped
case cancelTapped
}
}

public enum InternalAction: Hashable, Sendable {
Expand Down Expand Up @@ -80,37 +73,39 @@ public struct AccountAndPersonaHiding: Sendable, FeatureReducer {
]
))
return .none
}
}

public func reduce(into state: inout State, internalAction: InternalAction) -> Effect<Action> {
switch internalAction {
case let .hiddenEntityCountsLoaded(counts):
state.hiddenEntityCounts = counts
return .none
case .didUnhideAllEntities:
state.hiddenEntityCounts = .init(hiddenAccountsCount: 0, hiddenPersonasCount: 0)
return .none
}
}

case let .confirmUnhideAllAlert(action):
public func reduce(into state: inout State, presentedAction: Destination.Action) -> Effect<Action> {
switch presentedAction {
case let .confirmUnhideAllAlert(confirmUnhideAllAlert):
defer {
state.destination = nil
}

switch action {
case .presented(.confirmTapped):
switch confirmUnhideAllAlert {
case .confirmTapped:
return .run { send in
try await entitiesVisibilityClient.unhideAllEntities()
overlayWindowClient.scheduleHUD(.updatedAccount)
await send(.internal(.didUnhideAllEntities))
} catch: { error, _ in
errorQueue.schedule(error)
}
case .presented(.cancelTapped):
return .none
case .dismiss:
case .cancelTapped:
return .none
}
}
}

public func reduce(into state: inout State, internalAction: InternalAction) -> Effect<Action> {
switch internalAction {
case let .hiddenEntityCountsLoaded(counts):
state.hiddenEntityCounts = counts
return .none
case .didUnhideAllEntities:
state.hiddenEntityCounts = .init(hiddenAccountsCount: 0, hiddenPersonasCount: 0)
return .none
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ final class AccountAndPersonaHidingTests: TestCase {
))
}

await store.send(.view(.confirmUnhideAllAlert(.presented(.confirmTapped)))) {
await store.send(.destination(.presented(.confirmUnhideAllAlert(.confirmTapped)))) {
$0.destination = nil
}

Expand Down Expand Up @@ -97,7 +97,7 @@ final class AccountAndPersonaHidingTests: TestCase {
))
}

await store.send(.view(.confirmUnhideAllAlert(.presented(.confirmTapped)))) {
await store.send(.destination(.presented(.confirmUnhideAllAlert(.confirmTapped)))) {
$0.destination = nil
}

Expand Down

0 comments on commit 45bbd6f

Please sign in to comment.