Skip to content

Commit

Permalink
feat: alert error
Browse files Browse the repository at this point in the history
  • Loading branch information
tomokisun committed Aug 27, 2024
1 parent 5ba9756 commit 687f581
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 0 deletions.
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 ConfirmationDialog: 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

0 comments on commit 687f581

Please sign in to comment.