From 687f581ec5f6894a8400bbaf7fb5d7a73053137d Mon Sep 17 00:00:00 2001 From: tomokisun <github@tomokisun.com> Date: Tue, 27 Aug 2024 18:18:32 +0900 Subject: [PATCH 1/3] feat: alert error --- .../MatchCore/Sources/AppLogic/AppLogic.swift | 7 +++++++ .../MatchCore/Sources/AppLogic/AuthLogic.swift | 15 +++++++++++++++ .../Sources/AppLogic/ConfigGlobalLogic.swift | 5 +++++ 3 files changed, 27 insertions(+) diff --git a/Packages/MatchCore/Sources/AppLogic/AppLogic.swift b/Packages/MatchCore/Sources/AppLogic/AppLogic.swift index 80a80a69..c2736398 100644 --- a/Packages/MatchCore/Sources/AppLogic/AppLogic.swift +++ b/Packages/MatchCore/Sources/AppLogic/AppLogic.swift @@ -258,14 +258,21 @@ public struct AppLogic { @Reducer public struct Destination { public enum State: Equatable { + case alert(AlertState<Action.Alert>) case receivedLike(ReceivedLikeRouterLogic.State = .loading) } public enum Action { + case alert(Alert) case receivedLike(ReceivedLikeRouterLogic.Action) + + public enum ConfirmationDialog: Equatable { + case confirm + } } public var body: some Reducer<State, Action> { + Scope(state: \.alert, action: \.alert) {} Scope(state: \.receivedLike, action: \.receivedLike, child: ReceivedLikeRouterLogic.init) } } diff --git a/Packages/MatchCore/Sources/AppLogic/AuthLogic.swift b/Packages/MatchCore/Sources/AppLogic/AuthLogic.swift index 0ad1ca1a..09f96622 100644 --- a/Packages/MatchCore/Sources/AppLogic/AuthLogic.swift +++ b/Packages/MatchCore/Sources/AppLogic/AuthLogic.swift @@ -53,6 +53,11 @@ public struct AuthLogic { case let .signInAnonymouslyResponse(.failure(error)): crashlytics.record(error: error) + state.destination = .alert( + AlertState { + TextState(error.localizedDescription) + } + ) state.child = .networkError() return .none @@ -69,6 +74,11 @@ public struct AuthLogic { case let .productsResponse(.failure(error)): crashlytics.record(error: error) + state.destination = .alert( + AlertState { + TextState(error.localizedDescription) + } + ) let countryCode = locale.region?.identifier return .run { send in @@ -96,6 +106,11 @@ public struct AuthLogic { case let .createUserResponse(.failure(error)): crashlytics.record(error: error) + state.destination = .alert( + AlertState { + TextState(error.localizedDescription) + } + ) state.child = .networkError() return .none diff --git a/Packages/MatchCore/Sources/AppLogic/ConfigGlobalLogic.swift b/Packages/MatchCore/Sources/AppLogic/ConfigGlobalLogic.swift index 6b2256e4..eacf1525 100644 --- a/Packages/MatchCore/Sources/AppLogic/ConfigGlobalLogic.swift +++ b/Packages/MatchCore/Sources/AppLogic/ConfigGlobalLogic.swift @@ -46,6 +46,11 @@ public struct ConfigGlobalLogic { case let .configResponse(.failure(error)): crashlytics.record(error: error) + state.destination = .alert( + AlertState { + TextState(error.localizedDescription) + } + ) state.account.isForceUpdate = .success(false) state.account.isMaintenance = .success(false) From dc45542743f1425518ee50cfe632b77266679c69 Mon Sep 17 00:00:00 2001 From: tomokisun <github@tomokisun.com> Date: Tue, 27 Aug 2024 18:19:44 +0900 Subject: [PATCH 2/3] chore: fix --- Packages/MatchCore/Sources/AppLogic/AppLogic.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Packages/MatchCore/Sources/AppLogic/AppLogic.swift b/Packages/MatchCore/Sources/AppLogic/AppLogic.swift index c2736398..dd501f2a 100644 --- a/Packages/MatchCore/Sources/AppLogic/AppLogic.swift +++ b/Packages/MatchCore/Sources/AppLogic/AppLogic.swift @@ -266,7 +266,7 @@ public struct AppLogic { case alert(Alert) case receivedLike(ReceivedLikeRouterLogic.Action) - public enum ConfirmationDialog: Equatable { + public enum Alert: Equatable { case confirm } } From 3cbc0fd6e16ef8b85b0eae9674f3dff4708e8cb0 Mon Sep 17 00:00:00 2001 From: tomokisun <github@tomokisun.com> Date: Tue, 27 Aug 2024 18:20:42 +0900 Subject: [PATCH 3/3] feat: app view --- Packages/PicMatch/Sources/AppFeature/AppLogic.swift | 1 + 1 file changed, 1 insertion(+) diff --git a/Packages/PicMatch/Sources/AppFeature/AppLogic.swift b/Packages/PicMatch/Sources/AppFeature/AppLogic.swift index a56b298f..105bcdf7 100644 --- a/Packages/PicMatch/Sources/AppFeature/AppLogic.swift +++ b/Packages/PicMatch/Sources/AppFeature/AppLogic.swift @@ -86,5 +86,6 @@ public struct AppView: View { store: store.scope(state: \.$destination.receivedLike, action: \.destination.receivedLike), content: ReceivedLikeRouterView.init(store:) ) + .alert(store: store.scope(state: \.$destination.alert, action: \.destination.alert)) } }