From 3d8b320879e43e73ba9e1c269d5e56d8b961d536 Mon Sep 17 00:00:00 2001 From: Jimmy-Prime Date: Fri, 15 Mar 2024 23:33:05 +0800 Subject: [PATCH] Rename `EffectTask` with `Effect` --- .../App/Tools/Clients/AppDelegateClient.swift | 10 +-- .../Tools/Clients/AuthorizationClient.swift | 2 +- .../App/Tools/Clients/ClipboardClient.swift | 4 +- EhPanda/App/Tools/Clients/CookieClient.swift | 20 +++--- EhPanda/App/Tools/Clients/DFClient.swift | 2 +- .../App/Tools/Clients/DatabaseClient.swift | 72 +++++++++---------- EhPanda/App/Tools/Clients/FileClient.swift | 6 +- EhPanda/App/Tools/Clients/ImageClient.swift | 10 +-- EhPanda/App/Tools/Clients/LibraryClient.swift | 10 +-- EhPanda/App/Tools/Clients/LoggerClient.swift | 4 +- .../Tools/Clients/UIApplicationClient.swift | 12 ++-- .../Tools/Clients/UserDefaultsClient.swift | 2 +- .../Tools/Extensions/Reducer_Extension.swift | 2 +- EhPanda/DataFlow/AppReducer.swift | 12 ++-- EhPanda/DataFlow/AppRouteReducer.swift | 4 +- EhPanda/Network/Request.swift | 2 +- .../Detail/Comments/CommentsReducer.swift | 2 +- EhPanda/View/Detail/DetailReducer.swift | 2 +- .../DetailSearch/DetailSearchReducer.swift | 2 +- EhPanda/View/Favorites/FavoritesReducer.swift | 2 +- .../Home/Frontpage/FrontpageReducer.swift | 2 +- EhPanda/View/Home/HomeReducer.swift | 2 +- .../View/Home/Toplists/ToplistsReducer.swift | 2 +- .../View/Home/Watched/WatchedReducer.swift | 2 +- EhPanda/View/Reading/ReadingReducer.swift | 10 +-- EhPanda/View/Search/SearchReducer.swift | 2 +- EhPanda/View/Setting/Login/LoginReducer.swift | 2 +- EhPanda/View/Setting/SettingReducer.swift | 12 ++-- 28 files changed, 108 insertions(+), 108 deletions(-) diff --git a/EhPanda/App/Tools/Clients/AppDelegateClient.swift b/EhPanda/App/Tools/Clients/AppDelegateClient.swift index a904cca7..2bb6074b 100644 --- a/EhPanda/App/Tools/Clients/AppDelegateClient.swift +++ b/EhPanda/App/Tools/Clients/AppDelegateClient.swift @@ -9,8 +9,8 @@ import SwiftUI import ComposableArchitecture struct AppDelegateClient { - let setOrientation: (UIInterfaceOrientationMask) -> EffectTask - let setOrientationMask: (UIInterfaceOrientationMask) -> EffectTask + let setOrientation: (UIInterfaceOrientationMask) -> Effect + let setOrientationMask: (UIInterfaceOrientationMask) -> Effect } extension AppDelegateClient { @@ -27,13 +27,13 @@ extension AppDelegateClient { } ) - func setPortraitOrientation() -> EffectTask { + func setPortraitOrientation() -> Effect { setOrientation(.portrait) } - func setAllOrientationMask() -> EffectTask { + func setAllOrientationMask() -> Effect { setOrientationMask([.all]) } - func setPortraitOrientationMask() -> EffectTask { + func setPortraitOrientationMask() -> Effect { setOrientationMask([.portrait, .portraitUpsideDown]) } } diff --git a/EhPanda/App/Tools/Clients/AuthorizationClient.swift b/EhPanda/App/Tools/Clients/AuthorizationClient.swift index 442811fe..7537a562 100644 --- a/EhPanda/App/Tools/Clients/AuthorizationClient.swift +++ b/EhPanda/App/Tools/Clients/AuthorizationClient.swift @@ -11,7 +11,7 @@ import ComposableArchitecture struct AuthorizationClient { let passcodeNotSet: () -> Bool - let localAuthroize: (String) -> EffectTask + let localAuthroize: (String) -> Effect } extension AuthorizationClient { diff --git a/EhPanda/App/Tools/Clients/ClipboardClient.swift b/EhPanda/App/Tools/Clients/ClipboardClient.swift index 4c72c63f..9a78c64f 100644 --- a/EhPanda/App/Tools/Clients/ClipboardClient.swift +++ b/EhPanda/App/Tools/Clients/ClipboardClient.swift @@ -12,8 +12,8 @@ import UniformTypeIdentifiers struct ClipboardClient { let url: () -> URL? let changeCount: () -> Int - let saveText: (String) -> EffectTask - let saveImage: (UIImage, Bool) -> EffectTask + let saveText: (String) -> Effect + let saveImage: (UIImage, Bool) -> Effect } extension ClipboardClient { diff --git a/EhPanda/App/Tools/Clients/CookieClient.swift b/EhPanda/App/Tools/Clients/CookieClient.swift index 86143d11..fcecc2a0 100644 --- a/EhPanda/App/Tools/Clients/CookieClient.swift +++ b/EhPanda/App/Tools/Clients/CookieClient.swift @@ -9,7 +9,7 @@ import Foundation import ComposableArchitecture struct CookieClient { - let clearAll: () -> EffectTask + let clearAll: () -> Effect let getCookie: (URL, String) -> CookieValue private let removeCookie: (URL, String) -> Void private let checkExistence: (URL, String) -> Bool @@ -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 { + func setOrEditCookie(for url: URL, key: String, value: String) -> Effect { .fireAndForget { if checkExistence(url, key) { editCookie(for: url, key: key, value: value) @@ -138,13 +138,13 @@ extension CookieClient { && !getCookie(url, Defaults.Cookie.ipbPassHash).rawValue.isEmpty && getCookie(url, Defaults.Cookie.igneous).rawValue.isEmpty } - func removeYay() -> EffectTask { + func removeYay() -> Effect { .fireAndForget { removeCookie(Defaults.URL.exhentai, Defaults.Cookie.yay) removeCookie(Defaults.URL.sexhentai, Defaults.Cookie.yay) } } - func syncExCookies() -> EffectTask { + func syncExCookies() -> Effect { .merge( [ Defaults.Cookie.ipbMemberId, @@ -160,13 +160,13 @@ extension CookieClient { } ) } - func ignoreOffensive() -> EffectTask { + func ignoreOffensive() -> Effect { .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 { + func fulfillAnotherHostField() -> Effect { let ehURL = Defaults.URL.ehentai let exURL = Defaults.URL.exhentai let memberIdKey = Defaults.Cookie.ipbMemberId @@ -218,8 +218,8 @@ extension CookieClient { // MARK: SetCookies extension CookieClient { - func setCookies(state: CookiesState, trimsSpaces: Bool = true) -> EffectTask { - let effects: [EffectTask] = state.allCases + func setCookies(state: CookiesState, trimsSpaces: Bool = true) -> Effect { + let effects: [Effect] = state.allCases .flatMap { subState in state.host.cookieURLs .map { @@ -233,7 +233,7 @@ extension CookieClient { } return effects.isEmpty ? .none : .merge(effects) } - func setCredentials(response: HTTPURLResponse) -> EffectTask { + func setCredentials(response: HTTPURLResponse) -> Effect { .fireAndForget { guard let setString = response.allHeaderFields["Set-Cookie"] as? String else { return } setString.components(separatedBy: ", ") @@ -252,7 +252,7 @@ extension CookieClient { } } } - func setSkipServer(response: HTTPURLResponse) -> EffectTask { + func setSkipServer(response: HTTPURLResponse) -> Effect { .fireAndForget { guard let setString = response.allHeaderFields["Set-Cookie"] as? String else { return } setString.components(separatedBy: ", ") diff --git a/EhPanda/App/Tools/Clients/DFClient.swift b/EhPanda/App/Tools/Clients/DFClient.swift index 54a900c5..a8a77382 100644 --- a/EhPanda/App/Tools/Clients/DFClient.swift +++ b/EhPanda/App/Tools/Clients/DFClient.swift @@ -10,7 +10,7 @@ import Kingfisher import ComposableArchitecture struct DFClient { - let setActive: (Bool) -> EffectTask + let setActive: (Bool) -> Effect } extension DFClient { diff --git a/EhPanda/App/Tools/Clients/DatabaseClient.swift b/EhPanda/App/Tools/Clients/DatabaseClient.swift index 574f0fb0..5684896d 100644 --- a/EhPanda/App/Tools/Clients/DatabaseClient.swift +++ b/EhPanda/App/Tools/Clients/DatabaseClient.swift @@ -11,8 +11,8 @@ import CoreData import ComposableArchitecture struct DatabaseClient { - let prepareDatabase: () -> EffectTask - let dropDatabase: () -> EffectTask + let prepareDatabase: () -> Effect + let dropDatabase: () -> Effect private let saveContext: () -> Void private let materializedObjects: (NSManagedObjectContext, NSPredicate) -> [NSManagedObject] } @@ -216,7 +216,7 @@ extension DatabaseClient { } return entity } - func fetchAppEnv() -> EffectTask { + func fetchAppEnv() -> Effect { Future { promise in DispatchQueue.main.async { promise(.success(fetchOrCreate(entityType: AppEnvMO.self).toEntity())) @@ -229,7 +229,7 @@ extension DatabaseClient { func fetchAppEnvSynchronously() -> AppEnv { fetchOrCreate(entityType: AppEnvMO.self).toEntity() } - func fetchGalleryState(gid: String) -> EffectTask { + func fetchGalleryState(gid: String) -> Effect { guard gid.isValidGID else { return .none } return Future { promise in DispatchQueue.main.async { @@ -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") @@ -274,13 +274,13 @@ 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) } @@ -288,7 +288,7 @@ extension DatabaseClient { // MARK: UpdateGallery extension DatabaseClient { - func updateGallery(gid: String, key: String, value: Any?) -> EffectTask { + func updateGallery(gid: String, key: String, value: Any?) -> Effect { guard gid.isValidGID else { return .none } return .fireAndForget { DispatchQueue.main.async { @@ -299,11 +299,11 @@ extension DatabaseClient { } } } - func updateLastOpenDate(gid: String, date: Date = .now) -> EffectTask { + func updateLastOpenDate(gid: String, date: Date = .now) -> Effect { guard gid.isValidGID else { return .none } return updateGallery(gid: gid, key: "lastOpenDate", value: date) } - func clearHistoryGalleries() -> EffectTask { + func clearHistoryGalleries() -> Effect { .fireAndForget { DispatchQueue.main.async { let predicate = NSPredicate(format: "lastOpenDate != nil") @@ -315,7 +315,7 @@ extension DatabaseClient { } } } - func cacheGalleries(_ galleries: [Gallery]) -> EffectTask { + func cacheGalleries(_ galleries: [Gallery]) -> Effect { .fireAndForget { DispatchQueue.main.async { for gallery in galleries.filter({ $0.id.isValidGID }) { @@ -348,7 +348,7 @@ extension DatabaseClient { // MARK: UpdateGalleryDetail extension DatabaseClient { - func cacheGalleryDetail(_ detail: GalleryDetail) -> EffectTask { + func cacheGalleryDetail(_ detail: GalleryDetail) -> Effect { guard detail.gid.isValidGID else { return .none } return .fireAndForget { DispatchQueue.main.async { @@ -386,7 +386,7 @@ extension DatabaseClient { // MARK: UpdateGalleryState extension DatabaseClient { - func updateGalleryState(gid: String, commitChanges: @escaping (GalleryStateMO) -> Void) -> EffectTask { + func updateGalleryState(gid: String, commitChanges: @escaping (GalleryStateMO) -> Void) -> Effect { guard gid.isValidGID else { return .none } return .fireAndForget { DispatchQueue.main.async { @@ -397,30 +397,30 @@ extension DatabaseClient { } } } - func updateGalleryState(gid: String, key: String, value: Any?) -> EffectTask { + func updateGalleryState(gid: String, key: String, value: Any?) -> Effect { guard gid.isValidGID else { return .none } return updateGalleryState(gid: gid) { stateMO in stateMO.setValue(value, forKeyPath: key) } } - func updateGalleryTags(gid: String, tags: [GalleryTag]) -> EffectTask { + func updateGalleryTags(gid: String, tags: [GalleryTag]) -> Effect { guard gid.isValidGID else { return .none } return updateGalleryState(gid: gid, key: "tags", value: tags.toData()) } - func updatePreviewConfig(gid: String, config: PreviewConfig) -> EffectTask { + func updatePreviewConfig(gid: String, config: PreviewConfig) -> Effect { guard gid.isValidGID else { return .none } return updateGalleryState(gid: gid, key: "previewConfig", value: config.toData()) } - func updateReadingProgress(gid: String, progress: Int) -> EffectTask { + func updateReadingProgress(gid: String, progress: Int) -> Effect { guard gid.isValidGID else { return .none } return updateGalleryState(gid: gid, key: "readingProgress", value: Int64(progress)) } - func updateComments(gid: String, comments: [GalleryComment]) -> EffectTask { + func updateComments(gid: String, comments: [GalleryComment]) -> Effect { guard gid.isValidGID else { return .none } return updateGalleryState(gid: gid, key: "comments", value: comments.toData()) } - func removeImageURLs(gid: String) -> EffectTask { + func removeImageURLs(gid: String) -> Effect { guard gid.isValidGID else { return .none } return updateGalleryState(gid: gid) { galleryStateMO in galleryStateMO.imageURLs = nil @@ -429,7 +429,7 @@ extension DatabaseClient { galleryStateMO.originalImageURLs = nil } } - func removeImageURLs() -> EffectTask { + func removeImageURLs() -> Effect { .fireAndForget { DispatchQueue.main.async { batchUpdate(entityType: GalleryStateMO.self) { galleryStateMOs in @@ -443,14 +443,14 @@ extension DatabaseClient { } } } - func removeExpiredImageURLs() -> EffectTask { + func removeExpiredImageURLs() -> Effect { fetchHistoryGalleries() .map { $0.filter { Date().timeIntervalSince($0.lastOpenDate ?? .distantPast) > .oneWeek } } .map { $0.map { removeImageURLs(gid: $0.id) } } - .map(EffectTask.merge) + .map(Effect.merge) .fireAndForget() } - func updateThumbnailURLs(gid: String, thumbnailURLs: [Int: URL]) -> EffectTask { + func updateThumbnailURLs(gid: String, thumbnailURLs: [Int: URL]) -> Effect { guard gid.isValidGID else { return .none } return updateGalleryState(gid: gid) { galleryStateMO in update(gid: gid, storedData: &galleryStateMO.thumbnailURLs, new: thumbnailURLs) @@ -458,14 +458,14 @@ extension DatabaseClient { } func updateImageURLs( gid: String, imageURLs: [Int: URL], originalImageURLs: [Int: URL] - ) -> EffectTask { + ) -> Effect { 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 { + func updatePreviewURLs(gid: String, previewURLs: [Int: URL]) -> Effect { guard gid.isValidGID else { return .none } return updateGalleryState(gid: gid) { galleryStateMO in update(gid: gid, storedData: &galleryStateMO.previewURLs, new: previewURLs) @@ -489,7 +489,7 @@ extension DatabaseClient { // MARK: UpdateAppEnv extension DatabaseClient { - func updateAppEnv(key: String, value: Any?) -> EffectTask { + func updateAppEnv(key: String, value: Any?) -> Effect { .fireAndForget { DispatchQueue.main.async { update( @@ -499,10 +499,10 @@ extension DatabaseClient { } } } - func updateSetting(_ setting: Setting) -> EffectTask { + func updateSetting(_ setting: Setting) -> Effect { updateAppEnv(key: "setting", value: setting.toData()) } - func updateFilter(_ filter: Filter, range: FilterRange) -> EffectTask { + func updateFilter(_ filter: Filter, range: FilterRange) -> Effect { let key: String switch range { case .search: @@ -514,21 +514,21 @@ extension DatabaseClient { } return updateAppEnv(key: key, value: filter.toData()) } - func updateTagTranslator(_ tagTranslator: TagTranslator) -> EffectTask { + func updateTagTranslator(_ tagTranslator: TagTranslator) -> Effect { updateAppEnv(key: "tagTranslator", value: tagTranslator.toData()) } - func updateUser(_ user: User) -> EffectTask { + func updateUser(_ user: User) -> Effect { updateAppEnv(key: "user", value: user.toData()) } - func updateHistoryKeywords(_ keywords: [String]) -> EffectTask { + func updateHistoryKeywords(_ keywords: [String]) -> Effect { updateAppEnv(key: "historyKeywords", value: keywords.toData()) } - func updateQuickSearchWords(_ words: [QuickSearchWord]) -> EffectTask { + func updateQuickSearchWords(_ words: [QuickSearchWord]) -> Effect { updateAppEnv(key: "quickSearchWords", value: words.toData()) } // Update User - func updateUserProperty(_ commitChanges: @escaping (inout User) -> Void) -> EffectTask { + func updateUserProperty(_ commitChanges: @escaping (inout User) -> Void) -> Effect { fetchAppEnv().map(\.user) .map { (user: User) -> User in var user = user @@ -538,12 +538,12 @@ extension DatabaseClient { .flatMap(updateUser) .eraseToEffect() } - func updateGreeting(_ greeting: Greeting) -> EffectTask { + func updateGreeting(_ greeting: Greeting) -> Effect { updateUserProperty { user in user.greeting = greeting } } - func updateGalleryFunds(galleryPoints: String, credits: String) -> EffectTask { + func updateGalleryFunds(galleryPoints: String, credits: String) -> Effect { updateUserProperty { user in user.credits = credits user.galleryPoints = galleryPoints diff --git a/EhPanda/App/Tools/Clients/FileClient.swift b/EhPanda/App/Tools/Clients/FileClient.swift index 15461dd9..0539e7a5 100644 --- a/EhPanda/App/Tools/Clients/FileClient.swift +++ b/EhPanda/App/Tools/Clients/FileClient.swift @@ -11,9 +11,9 @@ import ComposableArchitecture struct FileClient { let createFile: (String, Data?) -> Bool - let fetchLogs: () -> EffectTask> - let deleteLog: (String) -> EffectTask> - let importTagTranslator: (URL) -> EffectTask> + let fetchLogs: () -> Effect> + let deleteLog: (String) -> Effect> + let importTagTranslator: (URL) -> Effect> } extension FileClient { diff --git a/EhPanda/App/Tools/Clients/ImageClient.swift b/EhPanda/App/Tools/Clients/ImageClient.swift index f31a8638..b5ef848a 100644 --- a/EhPanda/App/Tools/Clients/ImageClient.swift +++ b/EhPanda/App/Tools/Clients/ImageClient.swift @@ -12,10 +12,10 @@ import Kingfisher import ComposableArchitecture struct ImageClient { - let prefetchImages: ([URL]) -> EffectTask - let saveImageToPhotoLibrary: (UIImage, Bool) -> EffectTask - let downloadImage: (URL) -> EffectTask> - let retrieveImage: (String) -> EffectTask> + let prefetchImages: ([URL]) -> Effect + let saveImageToPhotoLibrary: (UIImage, Bool) -> Effect + let downloadImage: (URL) -> Effect> + let retrieveImage: (String) -> Effect> } extension ImageClient { @@ -78,7 +78,7 @@ extension ImageClient { } ) - func fetchImage(url: URL) -> EffectTask> { + func fetchImage(url: URL) -> Effect> { if KingfisherManager.shared.cache.isCached(forKey: url.absoluteString) { return retrieveImage(url.absoluteString) } else { diff --git a/EhPanda/App/Tools/Clients/LibraryClient.swift b/EhPanda/App/Tools/Clients/LibraryClient.swift index 5f566e54..a4063444 100644 --- a/EhPanda/App/Tools/Clients/LibraryClient.swift +++ b/EhPanda/App/Tools/Clients/LibraryClient.swift @@ -14,11 +14,11 @@ import UIImageColors import ComposableArchitecture struct LibraryClient { - let initializeLogger: () -> EffectTask - let initializeWebImage: () -> EffectTask - let clearWebImageDiskCache: () -> EffectTask - let analyzeImageColors: (UIImage) -> EffectTask - let calculateWebImageDiskCacheSize: () -> EffectTask + let initializeLogger: () -> Effect + let initializeWebImage: () -> Effect + let clearWebImageDiskCache: () -> Effect + let analyzeImageColors: (UIImage) -> Effect + let calculateWebImageDiskCacheSize: () -> Effect } extension LibraryClient { diff --git a/EhPanda/App/Tools/Clients/LoggerClient.swift b/EhPanda/App/Tools/Clients/LoggerClient.swift index ebeefb83..6c1a2b63 100644 --- a/EhPanda/App/Tools/Clients/LoggerClient.swift +++ b/EhPanda/App/Tools/Clients/LoggerClient.swift @@ -8,8 +8,8 @@ import ComposableArchitecture struct LoggerClient { - let info: (Any, Any?) -> EffectTask - let error: (Any, Any?) -> EffectTask + let info: (Any, Any?) -> Effect + let error: (Any, Any?) -> Effect } extension LoggerClient { diff --git a/EhPanda/App/Tools/Clients/UIApplicationClient.swift b/EhPanda/App/Tools/Clients/UIApplicationClient.swift index 97aef088..5b684af7 100644 --- a/EhPanda/App/Tools/Clients/UIApplicationClient.swift +++ b/EhPanda/App/Tools/Clients/UIApplicationClient.swift @@ -10,11 +10,11 @@ import Combine import ComposableArchitecture struct UIApplicationClient { - let openURL: (URL) -> EffectTask - let hideKeyboard: () -> EffectTask + let openURL: (URL) -> Effect + let hideKeyboard: () -> Effect let alternateIconName: () -> String? - let setAlternateIconName: (String?) -> EffectTask> - let setUserInterfaceStyle: (UIUserInterfaceStyle) -> EffectTask + let setAlternateIconName: (String?) -> Effect> + let setUserInterfaceStyle: (UIUserInterfaceStyle) -> Effect } extension UIApplicationClient { @@ -51,13 +51,13 @@ extension UIApplicationClient { } } ) - func openSettings() -> EffectTask { + func openSettings() -> Effect { if let url = URL(string: UIApplication.openSettingsURLString) { return openURL(url) } return .none } - func openFileApp() -> EffectTask { + func openFileApp() -> Effect { if let dirPath = FileUtil.logsDirectoryURL?.path, let dirURL = URL(string: "shareddocuments://" + dirPath) { diff --git a/EhPanda/App/Tools/Clients/UserDefaultsClient.swift b/EhPanda/App/Tools/Clients/UserDefaultsClient.swift index c403f278..ab6630f2 100644 --- a/EhPanda/App/Tools/Clients/UserDefaultsClient.swift +++ b/EhPanda/App/Tools/Clients/UserDefaultsClient.swift @@ -9,7 +9,7 @@ import Foundation import ComposableArchitecture struct UserDefaultsClient { - let setValue: (Any, AppUserDefaults) -> EffectTask + let setValue: (Any, AppUserDefaults) -> Effect } extension UserDefaultsClient { diff --git a/EhPanda/App/Tools/Extensions/Reducer_Extension.swift b/EhPanda/App/Tools/Extensions/Reducer_Extension.swift index 1fe1c4ae..459f0249 100644 --- a/EhPanda/App/Tools/Extensions/Reducer_Extension.swift +++ b/EhPanda/App/Tools/Extensions/Reducer_Extension.swift @@ -23,7 +23,7 @@ extension ReducerProtocol { private func onBecomeNonNil( unwrapping enum: @escaping (State) -> Enum?, case casePath: CasePath, - perform additionalEffects: @escaping (inout State, Action) -> EffectTask + perform additionalEffects: @escaping (inout State, Action) -> Effect ) -> some ReducerProtocol { Reduce { state, action in let previousCase = Binding.constant(`enum`(state)).case(casePath).wrappedValue diff --git a/EhPanda/DataFlow/AppReducer.swift b/EhPanda/DataFlow/AppReducer.swift index f67bca86..5b5ae387 100644 --- a/EhPanda/DataFlow/AppReducer.swift +++ b/EhPanda/DataFlow/AppReducer.swift @@ -82,7 +82,7 @@ struct AppReducer: ReducerProtocol { return .none case .appRoute(.clearSubStates): - var effects = [EffectTask]() + var effects = [Effect]() if deviceClient.isPad() { state.settingState.route = nil effects.append(.init(value: .setting(.clearSubStates))) @@ -93,7 +93,7 @@ struct AppReducer: ReducerProtocol { return .none case .appLock(.unlockApp): - var effects: [EffectTask] = [ + var effects: [Effect] = [ .init(value: .setting(.fetchGreeting)) ] if state.settingState.setting.detectsLinksFromClipboard { @@ -105,8 +105,8 @@ struct AppReducer: ReducerProtocol { return .none case .tabBar(.setTabBarItemType(let type)): - var effects = [EffectTask]() - let hapticEffect: EffectTask = .fireAndForget({ hapticsClient.generateFeedback(.soft) }) + var effects = [Effect]() + let hapticEffect: Effect = .fireAndForget({ hapticsClient.generateFeedback(.soft) }) if type == state.tabBarState.tabBarItemType { switch type { case .home: @@ -148,7 +148,7 @@ struct AppReducer: ReducerProtocol { return .none case .home(.watched(.onNotLoginViewButtonTapped)), .favorites(.onNotLoginViewButtonTapped): - var effects: [EffectTask] = [ + var effects: [Effect] = [ .fireAndForget({ hapticsClient.generateFeedback(.soft) }), .init(value: .tabBar(.setTabBarItemType(.setting))) ] @@ -175,7 +175,7 @@ struct AppReducer: ReducerProtocol { return .none case .setting(.loadUserSettingsDone): - var effects = [EffectTask]() + var effects = [Effect]() let threshold = state.settingState.setting.autoLockPolicy.rawValue let blurRadius = state.settingState.setting.backgroundBlurRadius if threshold >= 0 { diff --git a/EhPanda/DataFlow/AppRouteReducer.swift b/EhPanda/DataFlow/AppRouteReducer.swift index 9b410b04..9f09f234 100644 --- a/EhPanda/DataFlow/AppRouteReducer.swift +++ b/EhPanda/DataFlow/AppRouteReducer.swift @@ -80,7 +80,7 @@ struct AppRouteReducer: ReducerProtocol { let currentChangeCount = clipboardClient.changeCount() guard currentChangeCount != userDefaultsClient .getValue(.clipboardChangeCount) else { return .none } - var effects: [EffectTask] = [ + var effects: [Effect] = [ userDefaultsClient .setValue(currentChangeCount, .clipboardChangeCount).fireAndForget() ] @@ -110,7 +110,7 @@ struct AppRouteReducer: ReducerProtocol { case .handleGalleryLink(let url): let (_, pageIndex, commentID) = urlClient.analyzeURL(url) let gid = urlClient.parseGalleryID(url) - var effects = [EffectTask]() + var effects = [Effect]() state.detailState = .init() effects.append(.init(value: .detail(.fetchDatabaseInfos(gid)))) if let pageIndex = pageIndex { diff --git a/EhPanda/Network/Request.swift b/EhPanda/Network/Request.swift index d739ee09..4fe237ed 100644 --- a/EhPanda/Network/Request.swift +++ b/EhPanda/Network/Request.swift @@ -16,7 +16,7 @@ protocol Request { var publisher: AnyPublisher { get } } extension Request { - var effect: EffectTask> { + var effect: Effect> { publisher.receive(on: DispatchQueue.main).catchToEffect() } diff --git a/EhPanda/View/Detail/Comments/CommentsReducer.swift b/EhPanda/View/Detail/Comments/CommentsReducer.swift index 98ebffaf..a3021341 100644 --- a/EhPanda/View/Detail/Comments/CommentsReducer.swift +++ b/EhPanda/View/Detail/Comments/CommentsReducer.swift @@ -135,7 +135,7 @@ struct CommentsReducer: ReducerProtocol { case .handleGalleryLink(let url): let (_, pageIndex, commentID) = urlClient.analyzeURL(url) let gid = urlClient.parseGalleryID(url) - var effects = [EffectTask]() + var effects = [Effect]() if let pageIndex = pageIndex { effects.append(.init(value: .updateReadingProgress(gid, pageIndex))) effects.append( diff --git a/EhPanda/View/Detail/DetailReducer.swift b/EhPanda/View/Detail/DetailReducer.swift index 67b0de73..848f78f9 100644 --- a/EhPanda/View/Detail/DetailReducer.swift +++ b/EhPanda/View/Detail/DetailReducer.swift @@ -259,7 +259,7 @@ struct DetailReducer: ReducerProtocol { state.loadingState = .idle switch result { case .success(let (galleryDetail, galleryState, apiKey, greeting)): - var effects: [EffectTask] = [ + var effects: [Effect] = [ .init(value: .syncGalleryTags), .init(value: .syncGalleryDetail), .init(value: .syncGalleryPreviewURLs), diff --git a/EhPanda/View/Detail/DetailSearch/DetailSearchReducer.swift b/EhPanda/View/Detail/DetailSearch/DetailSearchReducer.swift index d1aa1d7b..e72f7cb7 100644 --- a/EhPanda/View/Detail/DetailSearch/DetailSearchReducer.swift +++ b/EhPanda/View/Detail/DetailSearch/DetailSearchReducer.swift @@ -145,7 +145,7 @@ struct DetailSearchReducer: ReducerProtocol { state.pageNumber = pageNumber state.insertGalleries(galleries) - var effects: [EffectTask] = [ + var effects: [Effect] = [ databaseClient.cacheGalleries(galleries).fireAndForget() ] if galleries.isEmpty, pageNumber.hasNextPage() { diff --git a/EhPanda/View/Favorites/FavoritesReducer.swift b/EhPanda/View/Favorites/FavoritesReducer.swift index c2c694cf..e23b0bf9 100644 --- a/EhPanda/View/Favorites/FavoritesReducer.swift +++ b/EhPanda/View/Favorites/FavoritesReducer.swift @@ -160,7 +160,7 @@ struct FavoritesReducer: ReducerProtocol { state.insertGalleries(index: targetFavIndex, galleries: galleries) state.sortOrder = sortOrder - var effects: [EffectTask] = [ + var effects: [Effect] = [ databaseClient.cacheGalleries(galleries).fireAndForget() ] if galleries.isEmpty, pageNumber.hasNextPage() { diff --git a/EhPanda/View/Home/Frontpage/FrontpageReducer.swift b/EhPanda/View/Home/Frontpage/FrontpageReducer.swift index b4574355..8dfd9900 100644 --- a/EhPanda/View/Home/Frontpage/FrontpageReducer.swift +++ b/EhPanda/View/Home/Frontpage/FrontpageReducer.swift @@ -132,7 +132,7 @@ struct FrontpageReducer: ReducerProtocol { state.pageNumber = pageNumber state.insertGalleries(galleries) - var effects: [EffectTask] = [ + var effects: [Effect] = [ databaseClient.cacheGalleries(galleries).fireAndForget() ] if galleries.isEmpty, pageNumber.hasNextPage() { diff --git a/EhPanda/View/Home/HomeReducer.swift b/EhPanda/View/Home/HomeReducer.swift index 0089bd72..d8e28cd6 100644 --- a/EhPanda/View/Home/HomeReducer.swift +++ b/EhPanda/View/Home/HomeReducer.swift @@ -145,7 +145,7 @@ struct HomeReducer: ReducerProtocol { case .fetchAllToplistsGalleries: return .merge( ToplistsType.allCases.map({ Action.fetchToplistsGalleries($0.categoryIndex) }) - .map(EffectTask.init) + .map(Effect.init) ) case .fetchPopularGalleries: diff --git a/EhPanda/View/Home/Toplists/ToplistsReducer.swift b/EhPanda/View/Home/Toplists/ToplistsReducer.swift index 6497de5b..95813414 100644 --- a/EhPanda/View/Home/Toplists/ToplistsReducer.swift +++ b/EhPanda/View/Home/Toplists/ToplistsReducer.swift @@ -181,7 +181,7 @@ struct ToplistsReducer: ReducerProtocol { state.rawPageNumber[type] = pageNumber state.insertGalleries(type: type, galleries: galleries) - var effects: [EffectTask] = [ + var effects: [Effect] = [ databaseClient.cacheGalleries(galleries).fireAndForget() ] if galleries.isEmpty, pageNumber.hasNextPage() { diff --git a/EhPanda/View/Home/Watched/WatchedReducer.swift b/EhPanda/View/Home/Watched/WatchedReducer.swift index 6f583d64..529419e5 100644 --- a/EhPanda/View/Home/Watched/WatchedReducer.swift +++ b/EhPanda/View/Home/Watched/WatchedReducer.swift @@ -141,7 +141,7 @@ struct WatchedReducer: ReducerProtocol { state.pageNumber = pageNumber state.insertGalleries(galleries) - var effects: [EffectTask] = [ + var effects: [Effect] = [ databaseClient.cacheGalleries(galleries).fireAndForget() ] if galleries.isEmpty, pageNumber.hasNextPage() { diff --git a/EhPanda/View/Reading/ReadingReducer.swift b/EhPanda/View/Reading/ReadingReducer.swift index 96b5560b..818a024c 100644 --- a/EhPanda/View/Reading/ReadingReducer.swift +++ b/EhPanda/View/Reading/ReadingReducer.swift @@ -204,7 +204,7 @@ struct ReadingReducer: ReducerProtocol { return .none case .setOrientationPortrait(let isPortrait): - var effects = [EffectTask]() + var effects = [Effect]() if isPortrait { effects.append(appDelegateClient.setPortraitOrientationMask().fireAndForget()) effects.append(appDelegateClient.setPortraitOrientation().fireAndForget()) @@ -217,7 +217,7 @@ struct ReadingReducer: ReducerProtocol { return .fireAndForget({ hapticsClient.generateFeedback(.light) }) case .onAppear(let gid, let enablesLandscape): - var effects: [EffectTask] = [ + var effects: [Effect] = [ .init(value: .fetchDatabaseInfos(gid)) ] if enablesLandscape { @@ -322,7 +322,7 @@ struct ReadingReducer: ReducerProtocol { .fireAndForget() case .teardown: - var effects: [EffectTask] = [ + var effects: [Effect] = [ .cancel(ids: CancelID.allCases) ] if !deviceClient.isPad() { @@ -406,7 +406,7 @@ struct ReadingReducer: ReducerProtocol { } var prefetchImageURLs = [URL]() var fetchImageURLIndices = [Int]() - var effects = [EffectTask]() + var effects = [Effect]() let previousUpperBound = max(index - 2, 1) let previousLowerBound = max(previousUpperBound - prefetchLimit / 2, 1) if previousUpperBound - previousLowerBound > 0 { @@ -509,7 +509,7 @@ struct ReadingReducer: ReducerProtocol { case .refetchNormalImageURLsDone(let index, let result): switch result { case .success(let (imageURLs, response)): - var effects = [EffectTask]() + var effects = [Effect]() if let response = response { effects.append(cookieClient.setSkipServer(response: response).fireAndForget()) } diff --git a/EhPanda/View/Search/SearchReducer.swift b/EhPanda/View/Search/SearchReducer.swift index f4ea5499..ecf4d46e 100644 --- a/EhPanda/View/Search/SearchReducer.swift +++ b/EhPanda/View/Search/SearchReducer.swift @@ -146,7 +146,7 @@ struct SearchReducer: ReducerProtocol { state.pageNumber = pageNumber state.insertGalleries(galleries) - var effects: [EffectTask] = [ + var effects: [Effect] = [ databaseClient.cacheGalleries(galleries).fireAndForget() ] if galleries.isEmpty, pageNumber.hasNextPage() { diff --git a/EhPanda/View/Setting/Login/LoginReducer.swift b/EhPanda/View/Setting/Login/LoginReducer.swift index fe2c7803..9cfc5a68 100644 --- a/EhPanda/View/Setting/Login/LoginReducer.swift +++ b/EhPanda/View/Setting/Login/LoginReducer.swift @@ -77,7 +77,7 @@ struct LoginReducer: ReducerProtocol { case .loginDone(let result): state.route = nil - var effects = [EffectTask]() + var effects = [Effect]() if cookieClient.didLogin { state.loginState = .idle effects.append(.fireAndForget({ hapticsClient.generateNotificationFeedback(.success) })) diff --git a/EhPanda/View/Setting/SettingReducer.swift b/EhPanda/View/Setting/SettingReducer.swift index 6aec4aac..8964867b 100644 --- a/EhPanda/View/Setting/SettingReducer.swift +++ b/EhPanda/View/Setting/SettingReducer.swift @@ -122,7 +122,7 @@ struct SettingReducer: ReducerProtocol { ) case .binding(\.$setting.enablesTagsExtension): - var effects: [EffectTask] = [ + var effects: [Effect] = [ .init(value: .syncSetting) ] if state.setting.enablesTagsExtension { @@ -160,7 +160,7 @@ struct SettingReducer: ReducerProtocol { return .init(value: .syncSetting) case .binding(\.$setting.enablesLandscape): - var effects: [EffectTask] = [ + var effects: [Effect] = [ .init(value: .syncSetting) ] if !state.setting.enablesLandscape && !deviceClient.isPad() { @@ -237,7 +237,7 @@ struct SettingReducer: ReducerProtocol { state.setting = appEnv.setting state.tagTranslator = appEnv.tagTranslator state.user = appEnv.user - var effects: [EffectTask] = [ + var effects: [Effect] = [ .init(value: .syncAppIconType), .init(value: .loadUserSettingsDone), .init(value: .syncUserInterfaceStyle), @@ -276,7 +276,7 @@ struct SettingReducer: ReducerProtocol { return IgneousRequest().effect.map(Action.fetchIgneousDone) case .fetchIgneousDone(let result): - var effects = [EffectTask]() + var effects = [Effect]() if case .success(let response) = result { effects.append(cookieClient.setCredentials(response: response).fireAndForget()) } @@ -353,7 +353,7 @@ struct SettingReducer: ReducerProtocol { else { return .none } state.tagTranslatorLoadingState = .loading - var databaseEffect: EffectTask? + var databaseEffect: Effect? if state.tagTranslator.language != language { state.tagTranslator = TagTranslator(language: language) databaseEffect = .init(value: .syncTagTranslator) @@ -383,7 +383,7 @@ struct SettingReducer: ReducerProtocol { return VerifyEhProfileRequest().effect.map(Action.fetchEhProfileIndexDone) case .fetchEhProfileIndexDone(let result): - var effects = [EffectTask]() + var effects = [Effect]() if case .success(let response) = result { if let profileValue = response.profileValue {