Skip to content

Commit

Permalink
Merge pull request #368 from Jimmy-Prime/jimmy/fix-tca-warnings
Browse files Browse the repository at this point in the history
Fix TCA Warnings
  • Loading branch information
chihchy authored Apr 4, 2024
2 parents 99906b7 + fdbbbc4 commit 6f04b56
Show file tree
Hide file tree
Showing 74 changed files with 907 additions and 900 deletions.
10 changes: 5 additions & 5 deletions EhPanda/App/Tools/Clients/AppDelegateClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import SwiftUI
import ComposableArchitecture

struct AppDelegateClient {
let setOrientation: (UIInterfaceOrientationMask) -> EffectTask<Never>
let setOrientationMask: (UIInterfaceOrientationMask) -> EffectTask<Never>
let setOrientation: (UIInterfaceOrientationMask) -> Effect<Never>
let setOrientationMask: (UIInterfaceOrientationMask) -> Effect<Never>
}

extension AppDelegateClient {
Expand All @@ -27,13 +27,13 @@ extension AppDelegateClient {
}
)

func setPortraitOrientation() -> EffectTask<Never> {
func setPortraitOrientation() -> Effect<Never> {
setOrientation(.portrait)
}
func setAllOrientationMask() -> EffectTask<Never> {
func setAllOrientationMask() -> Effect<Never> {
setOrientationMask([.all])
}
func setPortraitOrientationMask() -> EffectTask<Never> {
func setPortraitOrientationMask() -> Effect<Never> {
setOrientationMask([.portrait, .portraitUpsideDown])
}
}
Expand Down
24 changes: 12 additions & 12 deletions EhPanda/App/Tools/Clients/AuthorizationClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import ComposableArchitecture

struct AuthorizationClient {
let passcodeNotSet: () -> Bool
let localAuthroize: (String) -> EffectTask<Bool>
let localAuthroize: (String) -> Effect<Bool>
}

extension AuthorizationClient {
Expand All @@ -21,21 +21,21 @@ extension AuthorizationClient {
return !LAContext().canEvaluatePolicy(.deviceOwnerAuthentication, error: &error)
},
localAuthroize: { reason in
Future { promise in
let context = LAContext()
var error: NSError?
Effect.publisher {
Future { promise in
let context = LAContext()
var error: NSError?

if context.canEvaluatePolicy(.deviceOwnerAuthentication, error: &error) {
context.evaluatePolicy(.deviceOwnerAuthentication, localizedReason: reason) { isSuccess, _ in
promise(.success(isSuccess))
if context.canEvaluatePolicy(.deviceOwnerAuthentication, error: &error) {
context.evaluatePolicy(.deviceOwnerAuthentication, localizedReason: reason) { isSuccess, _ in
promise(.success(isSuccess))
}
} else {
promise(.success(false))
}
} else {
promise(.success(false))
}
.receive(on: DispatchQueue.main)
}
.eraseToAnyPublisher()
.receive(on: DispatchQueue.main)
.eraseToEffect()
}
)
}
Expand Down
12 changes: 6 additions & 6 deletions EhPanda/App/Tools/Clients/ClipboardClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ import UniformTypeIdentifiers
struct ClipboardClient {
let url: () -> URL?
let changeCount: () -> Int
let saveText: (String) -> EffectTask<Never>
let saveImage: (UIImage, Bool) -> EffectTask<Never>
let saveText: (String) -> Effect<Never>
let saveImage: (UIImage, Bool) -> Effect<Never>
}

extension ClipboardClient {
Expand All @@ -29,12 +29,12 @@ extension ClipboardClient {
UIPasteboard.general.changeCount
},
saveText: { text in
.fireAndForget {
.run(operation: { _ in
UIPasteboard.general.string = text
}
})
},
saveImage: { (image, isAnimated) in
.fireAndForget {
.run(operation: { _ in
if isAnimated {
DispatchQueue.global(qos: .utility).async {
if let data = image.kf.data(format: .GIF) {
Expand All @@ -44,7 +44,7 @@ extension ClipboardClient {
} else {
UIPasteboard.general.image = image
}
}
})
}
)
}
Expand Down
40 changes: 20 additions & 20 deletions EhPanda/App/Tools/Clients/CookieClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import Foundation
import ComposableArchitecture

struct CookieClient {
let clearAll: () -> EffectTask<Never>
let clearAll: () -> Effect<Never>
let getCookie: (URL, String) -> CookieValue
private let removeCookie: (URL, String) -> Void
private let checkExistence: (URL, String) -> Bool
Expand All @@ -19,13 +19,13 @@ struct CookieClient {
extension CookieClient {
static let live: Self = .init(
clearAll: {
.fireAndForget {
.run(operation: { _ in
if let historyCookies = HTTPCookieStorage.shared.cookies {
historyCookies.forEach {
HTTPCookieStorage.shared.deleteCookie($0)
}
}
}
})
},
getCookie: { url, key in
var value = CookieValue(
Expand Down Expand Up @@ -108,14 +108,14 @@ extension CookieClient {
guard let cookie = newCookie else { return }
HTTPCookieStorage.shared.setCookie(cookie)
}
func setOrEditCookie(for url: URL, key: String, value: String) -> EffectTask<Never> {
.fireAndForget {
func setOrEditCookie(for url: URL, key: String, value: String) -> Effect<Never> {
.run(operation: { _ in
if checkExistence(url, key) {
editCookie(for: url, key: key, value: value)
} else {
setCookie(for: url, key: key, value: value)
}
}
})
}
}

Expand All @@ -138,13 +138,13 @@ extension CookieClient {
&& !getCookie(url, Defaults.Cookie.ipbPassHash).rawValue.isEmpty
&& getCookie(url, Defaults.Cookie.igneous).rawValue.isEmpty
}
func removeYay() -> EffectTask<Never> {
.fireAndForget {
func removeYay() -> Effect<Never> {
.run(operation: { _ in
removeCookie(Defaults.URL.exhentai, Defaults.Cookie.yay)
removeCookie(Defaults.URL.sexhentai, Defaults.Cookie.yay)
}
})
}
func syncExCookies() -> EffectTask<Never> {
func syncExCookies() -> Effect<Never> {
.merge(
[
Defaults.Cookie.ipbMemberId,
Expand All @@ -160,13 +160,13 @@ extension CookieClient {
}
)
}
func ignoreOffensive() -> EffectTask<Never> {
func ignoreOffensive() -> Effect<Never> {
.merge(
setOrEditCookie(for: Defaults.URL.ehentai, key: Defaults.Cookie.ignoreOffensive, value: "1"),
setOrEditCookie(for: Defaults.URL.exhentai, key: Defaults.Cookie.ignoreOffensive, value: "1")
)
}
func fulfillAnotherHostField() -> EffectTask<Never> {
func fulfillAnotherHostField() -> Effect<Never> {
let ehURL = Defaults.URL.ehentai
let exURL = Defaults.URL.exhentai
let memberIdKey = Defaults.Cookie.ipbMemberId
Expand Down Expand Up @@ -218,8 +218,8 @@ extension CookieClient {

// MARK: SetCookies
extension CookieClient {
func setCookies(state: CookiesState, trimsSpaces: Bool = true) -> EffectTask<Never> {
let effects: [EffectTask<Never>] = state.allCases
func setCookies(state: CookiesState, trimsSpaces: Bool = true) -> Effect<Never> {
let effects: [Effect<Never>] = state.allCases
.flatMap { subState in
state.host.cookieURLs
.map {
Expand All @@ -233,8 +233,8 @@ extension CookieClient {
}
return effects.isEmpty ? .none : .merge(effects)
}
func setCredentials(response: HTTPURLResponse) -> EffectTask<Never> {
.fireAndForget {
func setCredentials(response: HTTPURLResponse) -> Effect<Never> {
.run(operation: { _ in
guard let setString = response.allHeaderFields["Set-Cookie"] as? String else { return }
setString.components(separatedBy: ", ")
.flatMap { $0.components(separatedBy: "; ") }.forEach { value in
Expand All @@ -250,10 +250,10 @@ extension CookieClient {
}
}
}
}
})
}
func setSkipServer(response: HTTPURLResponse) -> EffectTask<Never> {
.fireAndForget {
func setSkipServer(response: HTTPURLResponse) -> Effect<Never> {
.run(operation: { _ in
guard let setString = response.allHeaderFields["Set-Cookie"] as? String else { return }
setString.components(separatedBy: ", ")
.flatMap { $0.components(separatedBy: "; ") }
Expand All @@ -266,7 +266,7 @@ extension CookieClient {
)
}
}
}
})
}
}

Expand Down
6 changes: 3 additions & 3 deletions EhPanda/App/Tools/Clients/DFClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ import Kingfisher
import ComposableArchitecture

struct DFClient {
let setActive: (Bool) -> EffectTask<Never>
let setActive: (Bool) -> Effect<Never>
}

extension DFClient {
static let live: Self = .init(
setActive: { newValue in
.fireAndForget {
.run(operation: { _ in
if newValue {
URLProtocol.registerClass(DFURLProtocol.self)
} else {
Expand All @@ -26,7 +26,7 @@ extension DFClient {
let config = KingfisherManager.shared.downloader.sessionConfiguration
config.protocolClasses = newValue ? [DFURLProtocol.self] : nil
KingfisherManager.shared.downloader.sessionConfiguration = config
}
})
}
)
}
Expand Down
Loading

0 comments on commit 6f04b56

Please sign in to comment.