diff --git a/secant/Features/Home/Views/HomeView.swift b/secant/Features/Home/Views/HomeView.swift index 278459f..9ea68de 100644 --- a/secant/Features/Home/Views/HomeView.swift +++ b/secant/Features/Home/Views/HomeView.swift @@ -52,7 +52,10 @@ struct HomeView: View { transaction: .demo, route: nil ), - reducer: .default.debug(), + reducer: SendReducer.default( + whenDone: { viewStore.send(.updateRoute(nil)) } + ) + .debug(), environment: () ) ) diff --git a/secant/Features/Send/SendStore.swift b/secant/Features/Send/SendStore.swift index 3f310a3..8483ab9 100644 --- a/secant/Features/Send/SendStore.swift +++ b/secant/Features/Send/SendStore.swift @@ -28,6 +28,17 @@ extension SendReducer { return .none } } + + static func `default`(whenDone: @escaping () -> Void) -> SendReducer { + SendReducer { state, action, _ in + switch action { + case let .updateRoute(route) where route == .showApprove(route: .showSent(route: .done)): + return Effect.fireAndForget(whenDone) + default: + return Self.default.run(&state, action, ()) + } + } + } } // Mark: - SendStore