Skip to content

Commit

Permalink
Enforce code style
Browse files Browse the repository at this point in the history
  • Loading branch information
chihchy committed Jul 10, 2024
1 parent 4463781 commit 5fe5ba1
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 38 deletions.
24 changes: 9 additions & 15 deletions EhPanda/View/Reading/ReadingReducer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -208,16 +208,10 @@ struct ReadingReducer: Reducer {
case .setOrientationPortrait(let isPortrait):
var effects = [Effect<Action>]()
if isPortrait {
effects.append(.run { _ in
appDelegateClient.setPortraitOrientationMask()
})
effects.append(.run { _ in
await appDelegateClient.setPortraitOrientation()
})
effects.append(.run(operation: { _ in appDelegateClient.setPortraitOrientationMask() }))
effects.append(.run(operation: { _ in await appDelegateClient.setPortraitOrientation() }))
} else {
effects.append(.run { _ in
appDelegateClient.setAllOrientationMask()
})
effects.append(.run(operation: { _ in appDelegateClient.setAllOrientationMask() }))
}
return .merge(effects)

Expand Down Expand Up @@ -453,9 +447,11 @@ struct ReadingReducer: Reducer {
fetchImageURLIndices.forEach {
effects.append(.send(.fetchImageURLs($0)))
}
effects.append(.run { [prefetchImageURLs] _ in
imageClient.prefetchImages(prefetchImageURLs)
})
effects.append(
.run { [prefetchImageURLs] _ in
imageClient.prefetchImages(prefetchImageURLs)
}
)
return .merge(effects)

case .fetchThumbnailURLs(let index):
Expand Down Expand Up @@ -552,9 +548,7 @@ struct ReadingReducer: Reducer {
case .success(let (imageURLs, response)):
var effects = [Effect<Action>]()
if let response = response {
effects.append(.run { _ in
cookieClient.setSkipServer(response: response)
})
effects.append(.run(operation: { _ in cookieClient.setSkipServer(response: response) }))
}
guard !imageURLs.isEmpty else {
state.imageURLLoadingStates[index] = .failed(.notFound)
Expand Down
12 changes: 3 additions & 9 deletions EhPanda/View/Setting/Login/LoginReducer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -85,19 +85,13 @@ struct LoginReducer: Reducer {
var effects = [Effect<Action>]()
if cookieClient.didLogin {
state.loginState = .idle
effects.append(.run { _ in
hapticsClient.generateNotificationFeedback(.success)
})
effects.append(.run(operation: { _ in hapticsClient.generateNotificationFeedback(.success) }))
} else {
state.loginState = .failed(.unknown)
effects.append(.run { _ in
hapticsClient.generateNotificationFeedback(.error)
})
effects.append(.run(operation: { _ in hapticsClient.generateNotificationFeedback(.error) }))
}
if case .success(let response) = result, let response = response {
effects.append(.run { _ in
cookieClient.setCredentials(response: response)
})
effects.append(.run(operation: { _ in cookieClient.setCredentials(response: response) }))
}
return .merge(effects)
}
Expand Down
24 changes: 10 additions & 14 deletions EhPanda/View/Setting/SettingReducer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -173,9 +173,7 @@ struct SettingReducer: Reducer {
.send(.syncSetting)
]
if !newValue && !deviceClient.isPad() {
effects.append(.run { _ in
appDelegateClient.setPortraitOrientationMask()
})
effects.append(.run(operation: { _ in appDelegateClient.setPortraitOrientationMask() }))
}
return .merge(effects)
}
Expand Down Expand Up @@ -320,9 +318,7 @@ struct SettingReducer: Reducer {
case .fetchIgneousDone(let result):
var effects = [Effect<Action>]()
if case .success(let response) = result {
effects.append(.run { _ in
cookieClient.setCredentials(response: response)
})
effects.append(.run(operation: { _ in cookieClient.setCredentials(response: response) }))
}
effects.append(.send(.account(.loadCookies)))
return .merge(effects)
Expand Down Expand Up @@ -447,19 +443,19 @@ struct SettingReducer: Reducer {

let cookieValue = cookieClient.getCookie(hostURL, selectedProfileKey)
if cookieValue.rawValue != profileValueString {
effects.append(.run { _ in
cookieClient.setOrEditCookie(
for: hostURL, key: selectedProfileKey, value: profileValueString
)
})
effects.append(
.run { _ in
cookieClient.setOrEditCookie(
for: hostURL, key: selectedProfileKey, value: profileValueString
)
}
)
}
} else if response.isProfileNotFound {
effects.append(.send(.createDefaultEhProfile))
} else {
let message = "Found profile but failed in parsing value."
effects.append(.run { _ in
loggerClient.error(message, nil)
})
effects.append(.run(operation: { _ in loggerClient.error(message, nil) }))
}
}
return effects.isEmpty ? .none : .merge(effects)
Expand Down

0 comments on commit 5fe5ba1

Please sign in to comment.