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

Fix build warning for AccountSettingReducer #357

Merged
merged 5 commits into from
Jan 27, 2024
Merged
Changes from all 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
16 changes: 7 additions & 9 deletions EhPanda/View/Setting/AccountSetting/AccountSettingReducer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,8 @@ struct AccountSettingReducer: ReducerProtocol {
case setNavigation(Route?)
case onLogoutConfirmButtonTapped
case clearSubStates

case loadCookies
case copyCookies(GalleryHost)

case login(LoginReducer.Action)
case ehSetting(EhSettingReducer.Action)
}
Expand All @@ -51,7 +49,7 @@ struct AccountSettingReducer: ReducerProtocol {
Reduce { state, action in
switch action {
case .binding(\.$route):
return state.route == nil ? .init(value: .clearSubStates) : .none
return state.route == nil ? .send(.clearSubStates) : .none

case .binding(\.$ehCookiesState):
return cookieClient.setCookies(state: state.ehCookiesState).fireAndForget()
Expand All @@ -64,17 +62,17 @@ struct AccountSettingReducer: ReducerProtocol {

case .setNavigation(let route):
state.route = route
return route == nil ? .init(value: .clearSubStates) : .none
return route == nil ? .send(.clearSubStates) : .none

case .onLogoutConfirmButtonTapped:
return .init(value: .loadCookies)
return .send(.loadCookies)

case .clearSubStates:
state.loginState = .init()
state.ehSettingState = .init()
return .merge(
.init(value: .login(.teardown)),
.init(value: .ehSetting(.teardown))
.send(.login(.teardown)),
.send(.ehSetting(.teardown))
)

case .loadCookies:
Expand All @@ -85,13 +83,13 @@ struct AccountSettingReducer: ReducerProtocol {
case .copyCookies(let host):
let cookiesDescription = cookieClient.getCookiesDescription(host: host)
return .merge(
.init(value: .setNavigation(.hud)),
.send(.setNavigation(.hud)),
clipboardClient.saveText(cookiesDescription).fireAndForget(),
.fireAndForget({ hapticsClient.generateNotificationFeedback(.success) })
)

case .login(.loginDone):
return cookieClient.didLogin ? .init(value: .setNavigation(nil)) : .none
return cookieClient.didLogin ? .send(.setNavigation(nil)) : .none

case .login:
return .none
Expand Down