From 45bbd6f6614451dd52b55ceec8610ab3c55bf311 Mon Sep 17 00:00:00 2001 From: Ghenadie <118184705+GhenadieVP@users.noreply.github.com> Date: Wed, 13 Mar 2024 15:14:47 +0200 Subject: [PATCH] Fix Account&Persona unhide (#1039) --- .../AccountAndPersonaHiding+Reducer.swift | 43 ++++++++----------- .../AccountAndPersonaHidingTests.swift | 4 +- 2 files changed, 21 insertions(+), 26 deletions(-) diff --git a/RadixWallet/Features/AccountAndPersonaHidingFeature/AccountAndPersonaHiding+Reducer.swift b/RadixWallet/Features/AccountAndPersonaHidingFeature/AccountAndPersonaHiding+Reducer.swift index ee99c706db..c1f65d6177 100644 --- a/RadixWallet/Features/AccountAndPersonaHidingFeature/AccountAndPersonaHiding+Reducer.swift +++ b/RadixWallet/Features/AccountAndPersonaHidingFeature/AccountAndPersonaHiding+Reducer.swift @@ -13,13 +13,6 @@ public struct AccountAndPersonaHiding: Sendable, FeatureReducer { public enum ViewAction: Hashable, Sendable { case task case unhideAllTapped - - case confirmUnhideAllAlert(PresentationAction) - - public enum ConfirmUnhideAllAlert: Hashable, Sendable { - case confirmTapped - case cancelTapped - } } public enum InternalAction: Hashable, Sendable { @@ -80,14 +73,29 @@ public struct AccountAndPersonaHiding: Sendable, FeatureReducer { ] )) return .none + } + } + + public func reduce(into state: inout State, internalAction: InternalAction) -> Effect { + 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 { + 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) @@ -95,22 +103,9 @@ public struct AccountAndPersonaHiding: Sendable, FeatureReducer { } 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 { - switch internalAction { - case let .hiddenEntityCountsLoaded(counts): - state.hiddenEntityCounts = counts - return .none - case .didUnhideAllEntities: - state.hiddenEntityCounts = .init(hiddenAccountsCount: 0, hiddenPersonasCount: 0) - return .none - } - } } diff --git a/RadixWalletTests/Features/AccountAndPersonaHidingTests/AccountAndPersonaHidingTests.swift b/RadixWalletTests/Features/AccountAndPersonaHidingTests/AccountAndPersonaHidingTests.swift index 6ddf615aa7..aaa970fcb7 100644 --- a/RadixWalletTests/Features/AccountAndPersonaHidingTests/AccountAndPersonaHidingTests.swift +++ b/RadixWalletTests/Features/AccountAndPersonaHidingTests/AccountAndPersonaHidingTests.swift @@ -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 } @@ -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 }