Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: alert error #1044

Merged
merged 3 commits into from
Aug 27, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions Packages/MatchCore/Sources/AppLogic/AppLogic.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 Alert: Equatable {
case confirm
}
}

public var body: some Reducer<State, Action> {
Scope(state: \.alert, action: \.alert) {}
Scope(state: \.receivedLike, action: \.receivedLike, child: ReceivedLikeRouterLogic.init)
}
}
Expand Down
15 changes: 15 additions & 0 deletions Packages/MatchCore/Sources/AppLogic/AuthLogic.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions Packages/MatchCore/Sources/AppLogic/ConfigGlobalLogic.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Loading