Skip to content

Commit

Permalink
Rename EffectTask with Effect
Browse files Browse the repository at this point in the history
  • Loading branch information
Jimmy-Prime committed Mar 15, 2024
1 parent 99906b7 commit 3d8b320
Show file tree
Hide file tree
Showing 28 changed files with 108 additions and 108 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
2 changes: 1 addition & 1 deletion 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 Down
4 changes: 2 additions & 2 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 Down
20 changes: 10 additions & 10 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 Down Expand Up @@ -108,7 +108,7 @@ extension CookieClient {
guard let cookie = newCookie else { return }
HTTPCookieStorage.shared.setCookie(cookie)
}
func setOrEditCookie(for url: URL, key: String, value: String) -> EffectTask<Never> {
func setOrEditCookie(for url: URL, key: String, value: String) -> Effect<Never> {
.fireAndForget {
if checkExistence(url, key) {
editCookie(for: url, key: key, value: value)
Expand Down Expand Up @@ -138,13 +138,13 @@ extension CookieClient {
&& !getCookie(url, Defaults.Cookie.ipbPassHash).rawValue.isEmpty
&& getCookie(url, Defaults.Cookie.igneous).rawValue.isEmpty
}
func removeYay() -> EffectTask<Never> {
func removeYay() -> Effect<Never> {
.fireAndForget {
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,7 +233,7 @@ extension CookieClient {
}
return effects.isEmpty ? .none : .merge(effects)
}
func setCredentials(response: HTTPURLResponse) -> EffectTask<Never> {
func setCredentials(response: HTTPURLResponse) -> Effect<Never> {
.fireAndForget {
guard let setString = response.allHeaderFields["Set-Cookie"] as? String else { return }
setString.components(separatedBy: ", ")
Expand All @@ -252,7 +252,7 @@ extension CookieClient {
}
}
}
func setSkipServer(response: HTTPURLResponse) -> EffectTask<Never> {
func setSkipServer(response: HTTPURLResponse) -> Effect<Never> {
.fireAndForget {
guard let setString = response.allHeaderFields["Set-Cookie"] as? String else { return }
setString.components(separatedBy: ", ")
Expand Down
2 changes: 1 addition & 1 deletion EhPanda/App/Tools/Clients/DFClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import Kingfisher
import ComposableArchitecture

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

extension DFClient {
Expand Down
72 changes: 36 additions & 36 deletions EhPanda/App/Tools/Clients/DatabaseClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import CoreData
import ComposableArchitecture

struct DatabaseClient {
let prepareDatabase: () -> EffectTask<AppError?>
let dropDatabase: () -> EffectTask<AppError?>
let prepareDatabase: () -> Effect<AppError?>
let dropDatabase: () -> Effect<AppError?>
private let saveContext: () -> Void
private let materializedObjects: (NSManagedObjectContext, NSPredicate) -> [NSManagedObject]
}
Expand Down Expand Up @@ -216,7 +216,7 @@ extension DatabaseClient {
}
return entity
}
func fetchAppEnv() -> EffectTask<AppEnv> {
func fetchAppEnv() -> Effect<AppEnv> {
Future { promise in
DispatchQueue.main.async {
promise(.success(fetchOrCreate(entityType: AppEnvMO.self).toEntity()))
Expand All @@ -229,7 +229,7 @@ extension DatabaseClient {
func fetchAppEnvSynchronously() -> AppEnv {
fetchOrCreate(entityType: AppEnvMO.self).toEntity()
}
func fetchGalleryState(gid: String) -> EffectTask<GalleryState> {
func fetchGalleryState(gid: String) -> Effect<GalleryState> {
guard gid.isValidGID else { return .none }
return Future { promise in
DispatchQueue.main.async {
Expand All @@ -242,7 +242,7 @@ extension DatabaseClient {
.receive(on: DispatchQueue.main)
.eraseToEffect()
}
func fetchHistoryGalleries(fetchLimit: Int = 0) -> EffectTask<[Gallery]> {
func fetchHistoryGalleries(fetchLimit: Int = 0) -> Effect<[Gallery]> {
Future { promise in
DispatchQueue.main.async {
let predicate = NSPredicate(format: "lastOpenDate != nil")
Expand Down Expand Up @@ -274,21 +274,21 @@ extension DatabaseClient {
return fetchAppEnvSynchronously().watchedFilter
}
}
func fetchHistoryKeywords() -> EffectTask<[String]> {
func fetchHistoryKeywords() -> Effect<[String]> {
fetchAppEnv().map(\.historyKeywords)
}
func fetchQuickSearchWords() -> EffectTask<[QuickSearchWord]> {
func fetchQuickSearchWords() -> Effect<[QuickSearchWord]> {
fetchAppEnv().map(\.quickSearchWords)
}
func fetchGalleryPreviewURLs(gid: String) -> EffectTask<[Int: URL]> {
func fetchGalleryPreviewURLs(gid: String) -> Effect<[Int: URL]> {
guard gid.isValidGID else { return .none }
return fetchGalleryState(gid: gid).map(\.previewURLs)
}
}

// MARK: UpdateGallery
extension DatabaseClient {
func updateGallery(gid: String, key: String, value: Any?) -> EffectTask<Never> {
func updateGallery(gid: String, key: String, value: Any?) -> Effect<Never> {
guard gid.isValidGID else { return .none }
return .fireAndForget {
DispatchQueue.main.async {
Expand All @@ -299,11 +299,11 @@ extension DatabaseClient {
}
}
}
func updateLastOpenDate(gid: String, date: Date = .now) -> EffectTask<Never> {
func updateLastOpenDate(gid: String, date: Date = .now) -> Effect<Never> {
guard gid.isValidGID else { return .none }
return updateGallery(gid: gid, key: "lastOpenDate", value: date)
}
func clearHistoryGalleries() -> EffectTask<Never> {
func clearHistoryGalleries() -> Effect<Never> {
.fireAndForget {
DispatchQueue.main.async {
let predicate = NSPredicate(format: "lastOpenDate != nil")
Expand All @@ -315,7 +315,7 @@ extension DatabaseClient {
}
}
}
func cacheGalleries(_ galleries: [Gallery]) -> EffectTask<Never> {
func cacheGalleries(_ galleries: [Gallery]) -> Effect<Never> {
.fireAndForget {
DispatchQueue.main.async {
for gallery in galleries.filter({ $0.id.isValidGID }) {
Expand Down Expand Up @@ -348,7 +348,7 @@ extension DatabaseClient {

// MARK: UpdateGalleryDetail
extension DatabaseClient {
func cacheGalleryDetail(_ detail: GalleryDetail) -> EffectTask<Never> {
func cacheGalleryDetail(_ detail: GalleryDetail) -> Effect<Never> {
guard detail.gid.isValidGID else { return .none }
return .fireAndForget {
DispatchQueue.main.async {
Expand Down Expand Up @@ -386,7 +386,7 @@ extension DatabaseClient {

// MARK: UpdateGalleryState
extension DatabaseClient {
func updateGalleryState(gid: String, commitChanges: @escaping (GalleryStateMO) -> Void) -> EffectTask<Never> {
func updateGalleryState(gid: String, commitChanges: @escaping (GalleryStateMO) -> Void) -> Effect<Never> {
guard gid.isValidGID else { return .none }
return .fireAndForget {
DispatchQueue.main.async {
Expand All @@ -397,30 +397,30 @@ extension DatabaseClient {
}
}
}
func updateGalleryState(gid: String, key: String, value: Any?) -> EffectTask<Never> {
func updateGalleryState(gid: String, key: String, value: Any?) -> Effect<Never> {
guard gid.isValidGID else { return .none }
return updateGalleryState(gid: gid) { stateMO in
stateMO.setValue(value, forKeyPath: key)
}
}
func updateGalleryTags(gid: String, tags: [GalleryTag]) -> EffectTask<Never> {
func updateGalleryTags(gid: String, tags: [GalleryTag]) -> Effect<Never> {
guard gid.isValidGID else { return .none }
return updateGalleryState(gid: gid, key: "tags", value: tags.toData())
}
func updatePreviewConfig(gid: String, config: PreviewConfig) -> EffectTask<Never> {
func updatePreviewConfig(gid: String, config: PreviewConfig) -> Effect<Never> {
guard gid.isValidGID else { return .none }
return updateGalleryState(gid: gid, key: "previewConfig", value: config.toData())
}
func updateReadingProgress(gid: String, progress: Int) -> EffectTask<Never> {
func updateReadingProgress(gid: String, progress: Int) -> Effect<Never> {
guard gid.isValidGID else { return .none }
return updateGalleryState(gid: gid, key: "readingProgress", value: Int64(progress))
}
func updateComments(gid: String, comments: [GalleryComment]) -> EffectTask<Never> {
func updateComments(gid: String, comments: [GalleryComment]) -> Effect<Never> {
guard gid.isValidGID else { return .none }
return updateGalleryState(gid: gid, key: "comments", value: comments.toData())
}

func removeImageURLs(gid: String) -> EffectTask<Never> {
func removeImageURLs(gid: String) -> Effect<Never> {
guard gid.isValidGID else { return .none }
return updateGalleryState(gid: gid) { galleryStateMO in
galleryStateMO.imageURLs = nil
Expand All @@ -429,7 +429,7 @@ extension DatabaseClient {
galleryStateMO.originalImageURLs = nil
}
}
func removeImageURLs() -> EffectTask<Never> {
func removeImageURLs() -> Effect<Never> {
.fireAndForget {
DispatchQueue.main.async {
batchUpdate(entityType: GalleryStateMO.self) { galleryStateMOs in
Expand All @@ -443,29 +443,29 @@ extension DatabaseClient {
}
}
}
func removeExpiredImageURLs() -> EffectTask<Never> {
func removeExpiredImageURLs() -> Effect<Never> {
fetchHistoryGalleries()
.map { $0.filter { Date().timeIntervalSince($0.lastOpenDate ?? .distantPast) > .oneWeek } }
.map { $0.map { removeImageURLs(gid: $0.id) } }
.map(EffectTask<Never>.merge)
.map(Effect<Never>.merge)
.fireAndForget()
}
func updateThumbnailURLs(gid: String, thumbnailURLs: [Int: URL]) -> EffectTask<Never> {
func updateThumbnailURLs(gid: String, thumbnailURLs: [Int: URL]) -> Effect<Never> {
guard gid.isValidGID else { return .none }
return updateGalleryState(gid: gid) { galleryStateMO in
update(gid: gid, storedData: &galleryStateMO.thumbnailURLs, new: thumbnailURLs)
}
}
func updateImageURLs(
gid: String, imageURLs: [Int: URL], originalImageURLs: [Int: URL]
) -> EffectTask<Never> {
) -> Effect<Never> {
guard gid.isValidGID else { return .none }
return updateGalleryState(gid: gid) { galleryStateMO in
update(gid: gid, storedData: &galleryStateMO.imageURLs, new: imageURLs)
update(gid: gid, storedData: &galleryStateMO.originalImageURLs, new: originalImageURLs)
}
}
func updatePreviewURLs(gid: String, previewURLs: [Int: URL]) -> EffectTask<Never> {
func updatePreviewURLs(gid: String, previewURLs: [Int: URL]) -> Effect<Never> {
guard gid.isValidGID else { return .none }
return updateGalleryState(gid: gid) { galleryStateMO in
update(gid: gid, storedData: &galleryStateMO.previewURLs, new: previewURLs)
Expand All @@ -489,7 +489,7 @@ extension DatabaseClient {

// MARK: UpdateAppEnv
extension DatabaseClient {
func updateAppEnv(key: String, value: Any?) -> EffectTask<Never> {
func updateAppEnv(key: String, value: Any?) -> Effect<Never> {
.fireAndForget {
DispatchQueue.main.async {
update(
Expand All @@ -499,10 +499,10 @@ extension DatabaseClient {
}
}
}
func updateSetting(_ setting: Setting) -> EffectTask<Never> {
func updateSetting(_ setting: Setting) -> Effect<Never> {
updateAppEnv(key: "setting", value: setting.toData())
}
func updateFilter(_ filter: Filter, range: FilterRange) -> EffectTask<Never> {
func updateFilter(_ filter: Filter, range: FilterRange) -> Effect<Never> {
let key: String
switch range {
case .search:
Expand All @@ -514,21 +514,21 @@ extension DatabaseClient {
}
return updateAppEnv(key: key, value: filter.toData())
}
func updateTagTranslator(_ tagTranslator: TagTranslator) -> EffectTask<Never> {
func updateTagTranslator(_ tagTranslator: TagTranslator) -> Effect<Never> {
updateAppEnv(key: "tagTranslator", value: tagTranslator.toData())
}
func updateUser(_ user: User) -> EffectTask<Never> {
func updateUser(_ user: User) -> Effect<Never> {
updateAppEnv(key: "user", value: user.toData())
}
func updateHistoryKeywords(_ keywords: [String]) -> EffectTask<Never> {
func updateHistoryKeywords(_ keywords: [String]) -> Effect<Never> {
updateAppEnv(key: "historyKeywords", value: keywords.toData())
}
func updateQuickSearchWords(_ words: [QuickSearchWord]) -> EffectTask<Never> {
func updateQuickSearchWords(_ words: [QuickSearchWord]) -> Effect<Never> {
updateAppEnv(key: "quickSearchWords", value: words.toData())
}

// Update User
func updateUserProperty(_ commitChanges: @escaping (inout User) -> Void) -> EffectTask<Never> {
func updateUserProperty(_ commitChanges: @escaping (inout User) -> Void) -> Effect<Never> {
fetchAppEnv().map(\.user)
.map { (user: User) -> User in
var user = user
Expand All @@ -538,12 +538,12 @@ extension DatabaseClient {
.flatMap(updateUser)
.eraseToEffect()
}
func updateGreeting(_ greeting: Greeting) -> EffectTask<Never> {
func updateGreeting(_ greeting: Greeting) -> Effect<Never> {
updateUserProperty { user in
user.greeting = greeting
}
}
func updateGalleryFunds(galleryPoints: String, credits: String) -> EffectTask<Never> {
func updateGalleryFunds(galleryPoints: String, credits: String) -> Effect<Never> {
updateUserProperty { user in
user.credits = credits
user.galleryPoints = galleryPoints
Expand Down
6 changes: 3 additions & 3 deletions EhPanda/App/Tools/Clients/FileClient.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ import ComposableArchitecture

struct FileClient {
let createFile: (String, Data?) -> Bool
let fetchLogs: () -> EffectTask<Result<[Log], AppError>>
let deleteLog: (String) -> EffectTask<Result<String, AppError>>
let importTagTranslator: (URL) -> EffectTask<Result<TagTranslator, AppError>>
let fetchLogs: () -> Effect<Result<[Log], AppError>>
let deleteLog: (String) -> Effect<Result<String, AppError>>
let importTagTranslator: (URL) -> Effect<Result<TagTranslator, AppError>>
}

extension FileClient {
Expand Down
Loading

0 comments on commit 3d8b320

Please sign in to comment.