diff --git a/EhPanda/App/Tools/Clients/AuthorizationClient.swift b/EhPanda/App/Tools/Clients/AuthorizationClient.swift index e4c1cefe..1bf6cffe 100644 --- a/EhPanda/App/Tools/Clients/AuthorizationClient.swift +++ b/EhPanda/App/Tools/Clients/AuthorizationClient.swift @@ -21,7 +21,7 @@ extension AuthorizationClient { return !LAContext().canEvaluatePolicy(.deviceOwnerAuthentication, error: &error) }, localAuthroize: { reason in - Effect.publisher { + .publisher { Future { promise in let context = LAContext() var error: NSError? diff --git a/EhPanda/App/Tools/Clients/DatabaseClient.swift b/EhPanda/App/Tools/Clients/DatabaseClient.swift index 8b141273..fccb55a2 100644 --- a/EhPanda/App/Tools/Clients/DatabaseClient.swift +++ b/EhPanda/App/Tools/Clients/DatabaseClient.swift @@ -20,7 +20,7 @@ struct DatabaseClient { extension DatabaseClient { static let live: Self = .init( prepareDatabase: { - Effect.publisher { + .publisher { Future { promise in PersistenceController.shared.prepare { switch $0 { @@ -36,7 +36,7 @@ extension DatabaseClient { } }, dropDatabase: { - Effect.publisher { + .publisher { Future { promise in PersistenceController.shared.rebuild { switch $0 { @@ -217,7 +217,7 @@ extension DatabaseClient { return entity } func fetchAppEnv() -> Effect { - Effect.publisher { + .publisher { Future { promise in DispatchQueue.main.async { promise(.success(fetchOrCreate(entityType: AppEnvMO.self).toEntity())) @@ -231,7 +231,7 @@ extension DatabaseClient { } func fetchGalleryState(gid: String) -> Effect { guard gid.isValidGID else { return .none } - return Effect.publisher { + return .publisher { Future { promise in DispatchQueue.main.async { promise(.success( @@ -243,7 +243,7 @@ extension DatabaseClient { } } func fetchHistoryGalleries(fetchLimit: Int = 0) -> Effect<[Gallery]> { - Effect.publisher { + .publisher { Future { promise in DispatchQueue.main.async { let predicate = NSPredicate(format: "lastOpenDate != nil") @@ -290,14 +290,14 @@ extension DatabaseClient { extension DatabaseClient { func updateGallery(gid: String, key: String, value: Any?) -> Effect { guard gid.isValidGID else { return .none } - return .run(operation: { _ in + return .run { _ in DispatchQueue.main.async { update( entityType: GalleryMO.self, gid: gid, createIfNil: true, commitChanges: { $0.setValue(value, forKeyPath: key) } ) } - }) + } } func updateLastOpenDate(gid: String, date: Date = .now) -> Effect { guard gid.isValidGID else { return .none } @@ -350,7 +350,7 @@ extension DatabaseClient { extension DatabaseClient { func cacheGalleryDetail(_ detail: GalleryDetail) -> Effect { guard detail.gid.isValidGID else { return .none } - return .run(operation: { _ in + return .run { _ in DispatchQueue.main.async { let storedMO = fetch( entityType: GalleryDetailMO.self, gid: detail.gid @@ -380,7 +380,7 @@ extension DatabaseClient { } saveContext() } - }) + } } } @@ -388,14 +388,14 @@ extension DatabaseClient { extension DatabaseClient { func updateGalleryState(gid: String, commitChanges: @escaping (GalleryStateMO) -> Void) -> Effect { guard gid.isValidGID else { return .none } - return .run(operation: { _ in + return .run { _ in DispatchQueue.main.async { update( entityType: GalleryStateMO.self, gid: gid, createIfNil: true, commitChanges: commitChanges ) } - }) + } } func updateGalleryState(gid: String, key: String, value: Any?) -> Effect { guard gid.isValidGID else { return .none } @@ -529,7 +529,7 @@ extension DatabaseClient { // Update User func updateUserProperty(_ commitChanges: @escaping (inout User) -> Void) -> Effect { - Effect.publisher { + .publisher { fetchAppEnv().map(\.user) .map { (user: User) -> User in var user = user diff --git a/EhPanda/App/Tools/Clients/ImageClient.swift b/EhPanda/App/Tools/Clients/ImageClient.swift index 43c142bd..0b7e9138 100644 --- a/EhPanda/App/Tools/Clients/ImageClient.swift +++ b/EhPanda/App/Tools/Clients/ImageClient.swift @@ -26,7 +26,7 @@ extension ImageClient { }) }, saveImageToPhotoLibrary: { (image, isAnimated) in - Effect.publisher { + .publisher { Future { promise in DispatchQueue.global(qos: .utility).async { if let data = image.kf.data(format: isAnimated ? .GIF : .unknown) { diff --git a/EhPanda/App/Tools/Clients/LibraryClient.swift b/EhPanda/App/Tools/Clients/LibraryClient.swift index 9861231a..bac83bc8 100644 --- a/EhPanda/App/Tools/Clients/LibraryClient.swift +++ b/EhPanda/App/Tools/Clients/LibraryClient.swift @@ -67,7 +67,7 @@ extension LibraryClient { }) }, analyzeImageColors: { image in - Effect.publisher { + .publisher { Future { promise in image.getColors(quality: .lowest) { colors in promise(.success(colors)) @@ -76,7 +76,7 @@ extension LibraryClient { } }, calculateWebImageDiskCacheSize: { - Effect.publisher { + .publisher { Future { promise in KingfisherManager.shared.cache.calculateDiskStorageSize { promise(.success(try? $0.get())) diff --git a/EhPanda/DataFlow/AppLockReducer.swift b/EhPanda/DataFlow/AppLockReducer.swift index e7850912..9e7bf19e 100644 --- a/EhPanda/DataFlow/AppLockReducer.swift +++ b/EhPanda/DataFlow/AppLockReducer.swift @@ -43,7 +43,7 @@ struct AppLockReducer: Reducer { Effect.send(.lockApp(blurRadius)) ) } else { - return Effect.send(.unlockApp) + return .send(.unlockApp) } case .onBecomeInactive(let blurRadius): diff --git a/EhPanda/DataFlow/AppReducer.swift b/EhPanda/DataFlow/AppReducer.swift index 18aa0a4d..7c59cfd6 100644 --- a/EhPanda/DataFlow/AppReducer.swift +++ b/EhPanda/DataFlow/AppReducer.swift @@ -50,7 +50,7 @@ struct AppReducer: Reducer { return state.appRouteState.route == nil ? Effect.send(.appRoute(.clearSubStates)) : .none case .binding(\.settingState.$setting): - return Effect.send(.setting(.syncSetting)) + return .send(.setting(.syncSetting)) case .binding: return .none @@ -62,11 +62,11 @@ struct AppReducer: Reducer { case .active: let threshold = state.settingState.setting.autoLockPolicy.rawValue let blurRadius = state.settingState.setting.backgroundBlurRadius - return Effect.send(.appLock(.onBecomeActive(threshold, blurRadius))) + return .send(.appLock(.onBecomeActive(threshold, blurRadius))) case .inactive: let blurRadius = state.settingState.setting.backgroundBlurRadius - return Effect.send(.appLock(.onBecomeInactive(blurRadius))) + return .send(.appLock(.onBecomeInactive(blurRadius))) default: return .none @@ -85,7 +85,7 @@ struct AppReducer: Reducer { var effects = [Effect]() if deviceClient.isPad() { state.settingState.route = nil - effects.append(Effect.send(.setting(.clearSubStates))) + effects.append(.send(.setting(.clearSubStates))) } return effects.isEmpty ? .none : .merge(effects) @@ -97,7 +97,7 @@ struct AppReducer: Reducer { Effect.send(.setting(.fetchGreeting)) ] if state.settingState.setting.detectsLinksFromClipboard { - effects.append(Effect.send(.appRoute(.detectClipboardURL))) + effects.append(.send(.appRoute(.detectClipboardURL))) } return .merge(effects) @@ -111,27 +111,27 @@ struct AppReducer: Reducer { switch type { case .home: if state.homeState.route != nil { - effects.append(Effect.send(.home(.setNavigation(nil)))) + effects.append(.send(.home(.setNavigation(nil)))) } else { - effects.append(Effect.send(.home(.fetchAllGalleries))) + effects.append(.send(.home(.fetchAllGalleries))) } case .favorites: if state.favoritesState.route != nil { - effects.append(Effect.send(.favorites(.setNavigation(nil)))) + effects.append(.send(.favorites(.setNavigation(nil)))) effects.append(hapticEffect) } else if cookieClient.didLogin { - effects.append(Effect.send(.favorites(.fetchGalleries()))) + effects.append(.send(.favorites(.fetchGalleries()))) effects.append(hapticEffect) } case .search: if state.searchRootState.route != nil { - effects.append(Effect.send(.searchRoot(.setNavigation(nil)))) + effects.append(.send(.searchRoot(.setNavigation(nil)))) } else { - effects.append(Effect.send(.searchRoot(.fetchDatabaseInfos))) + effects.append(.send(.searchRoot(.fetchDatabaseInfos))) } case .setting: if state.settingState.route != nil { - effects.append(Effect.send(.setting(.setNavigation(nil)))) + effects.append(.send(.setting(.setNavigation(nil)))) effects.append(hapticEffect) } } @@ -140,7 +140,7 @@ struct AppReducer: Reducer { } } if type == .setting && deviceClient.isPad() { - effects.append(Effect.send(.appRoute(.setNavigation(.setting)))) + effects.append(.send(.appRoute(.setNavigation(.setting)))) } return effects.isEmpty ? .none : .merge(effects) @@ -152,10 +152,10 @@ struct AppReducer: Reducer { .run(operation: { _ in hapticsClient.generateFeedback(.soft) }), Effect.send(.tabBar(.setTabBarItemType(.setting))) ] - effects.append(Effect.send(.setting(.setNavigation(.account)))) + effects.append(.send(.setting(.setNavigation(.account)))) if !cookieClient.didLogin { effects.append( - Effect.publisher { + .publisher { Effect.send(.setting(.account(.setNavigation(.login)))) .delay( for: .milliseconds(deviceClient.isPad() ? 1200 : 200), @@ -181,15 +181,15 @@ struct AppReducer: Reducer { let blurRadius = state.settingState.setting.backgroundBlurRadius if threshold >= 0 { state.appLockState.becameInactiveDate = .distantPast - effects.append(Effect.send(.appLock(.onBecomeActive(threshold, blurRadius)))) + effects.append(.send(.appLock(.onBecomeActive(threshold, blurRadius)))) } if state.settingState.setting.detectsLinksFromClipboard { - effects.append(Effect.send(.appRoute(.detectClipboardURL))) + effects.append(.send(.appRoute(.detectClipboardURL))) } return effects.isEmpty ? .none : .merge(effects) case .setting(.fetchGreetingDone(let result)): - return Effect.send(.appRoute(.fetchGreetingDone(result))) + return .send(.appRoute(.fetchGreetingDone(result))) case .setting: return .none diff --git a/EhPanda/DataFlow/AppRouteReducer.swift b/EhPanda/DataFlow/AppRouteReducer.swift index bcc9460a..f408db58 100644 --- a/EhPanda/DataFlow/AppRouteReducer.swift +++ b/EhPanda/DataFlow/AppRouteReducer.swift @@ -74,7 +74,7 @@ struct AppRouteReducer: Reducer { case .clearSubStates: state.detailState = .init() - return Effect.send(.detail(.teardown)) + return .send(.detail(.teardown)) case .detectClipboardURL: let currentChangeCount = clipboardClient.changeCount() @@ -85,7 +85,7 @@ struct AppRouteReducer: Reducer { .setValue(currentChangeCount, .clipboardChangeCount).fireAndForget() ] if let url = clipboardClient.url() { - effects.append(Effect.send(.handleDeepLink(url))) + effects.append(.send(.handleDeepLink(url))) } return .merge(effects) @@ -101,12 +101,12 @@ struct AppRouteReducer: Reducer { let (isGalleryImageURL, _, _) = urlClient.analyzeURL(url) let gid = urlClient.parseGalleryID(url) guard databaseClient.fetchGallery(gid: gid) == nil else { - return Effect.publisher { + return .publisher { Effect.send(.handleGalleryLink(url)) .delay(for: .milliseconds(delay + 250), scheduler: DispatchQueue.main) } } - return Effect.publisher { + return .publisher { Effect.send(.fetchGallery(url, isGalleryImageURL)) .delay(for: .milliseconds(delay), scheduler: DispatchQueue.main) } @@ -116,11 +116,11 @@ struct AppRouteReducer: Reducer { let gid = urlClient.parseGalleryID(url) var effects = [Effect]() state.detailState = .init() - effects.append(Effect.send(.detail(.fetchDatabaseInfos(gid)))) + effects.append(.send(.detail(.fetchDatabaseInfos(gid)))) if let pageIndex = pageIndex { - effects.append(Effect.send(.updateReadingProgress(gid, pageIndex))) + effects.append(.send(.updateReadingProgress(gid, pageIndex))) effects.append( - Effect.publisher { + .publisher { Effect.send(.detail(.setNavigation(.reading))) .delay(for: .milliseconds(500), scheduler: DispatchQueue.main) } @@ -128,13 +128,13 @@ struct AppRouteReducer: Reducer { } else if let commentID = commentID { state.detailState.commentsState?.scrollCommentID = commentID effects.append( - Effect.publisher { + .publisher { Effect.send(.detail(.setNavigation(.comments(url)))) .delay(for: .milliseconds(500), scheduler: DispatchQueue.main) } ) } - effects.append(Effect.send(.setNavigation(.detail(gid)))) + effects.append(.send(.setNavigation(.detail(gid)))) return .merge(effects) case .updateReadingProgress(let gid, let progress): @@ -156,7 +156,7 @@ struct AppRouteReducer: Reducer { Effect.send(.handleGalleryLink(url)) ) case .failure: - return Effect.publisher { + return .publisher { Effect.send(Action.setHUDConfig(.error)) .delay(for: .milliseconds(500), scheduler: DispatchQueue.main) } @@ -164,7 +164,7 @@ struct AppRouteReducer: Reducer { case .fetchGreetingDone(let result): if case .success(let greeting) = result, !greeting.gainedNothing { - return Effect.send(.setNavigation(.newDawn(greeting))) + return .send(.setNavigation(.newDawn(greeting))) } return .none diff --git a/EhPanda/View/Detail/Archives/ArchivesReducer.swift b/EhPanda/View/Detail/Archives/ArchivesReducer.swift index 20e84c2e..d1c4c500 100644 --- a/EhPanda/View/Detail/Archives/ArchivesReducer.swift +++ b/EhPanda/View/Detail/Archives/ArchivesReducer.swift @@ -85,9 +85,9 @@ struct ArchivesReducer: Reducer { } state.hathArchives = archive.hathArchives if let galleryPoints = galleryPoints, let credits = credits { - return Effect.send(.syncGalleryFunds(galleryPoints, credits)) + return .send(.syncGalleryFunds(galleryPoints, credits)) } else if cookieClient.isSameAccount { - return Effect.send(.fetchArchiveFunds(gid, galleryURL)) + return .send(.fetchArchiveFunds(gid, galleryURL)) } else { return .none } @@ -103,7 +103,7 @@ struct ArchivesReducer: Reducer { case .fetchArchiveFundsDone(let result): if case .success(let (galleryPoints, credits)) = result { - return Effect.send(.syncGalleryFunds(galleryPoints, credits)) + return .send(.syncGalleryFunds(galleryPoints, credits)) } return .none @@ -140,7 +140,9 @@ struct ArchivesReducer: Reducer { state.messageHUDConfig = .error isSuccess = false } - return .run(operation: { _ in hapticsClient.generateNotificationFeedback(isSuccess ? .success : .error) }) + return .run { _ in + hapticsClient.generateNotificationFeedback(isSuccess ? .success : .error) + } } } } diff --git a/EhPanda/View/Detail/Archives/ArchivesView.swift b/EhPanda/View/Detail/Archives/ArchivesView.swift index 6e4bf1d1..6ba83b28 100644 --- a/EhPanda/View/Detail/Archives/ArchivesView.swift +++ b/EhPanda/View/Detail/Archives/ArchivesView.swift @@ -221,9 +221,7 @@ private struct DownloadButton: View { struct ArchivesView_Previews: PreviewProvider { static var previews: some View { ArchivesView( - store: .init(initialState: .init()) { - ArchivesReducer() - }, + store: .init(initialState: .init(), reducer: ArchivesReducer.init), gid: .init(), user: .init(), galleryURL: .mock, diff --git a/EhPanda/View/Detail/Comments/CommentsReducer.swift b/EhPanda/View/Detail/Comments/CommentsReducer.swift index ec06ff54..9d6a341d 100644 --- a/EhPanda/View/Detail/Comments/CommentsReducer.swift +++ b/EhPanda/View/Detail/Comments/CommentsReducer.swift @@ -89,7 +89,7 @@ struct CommentsReducer: Reducer { state.detailState = .init() state.commentContent = .init() state.postCommentFocused = false - return Effect.send(.detail(.teardown)) + return .send(.detail(.teardown)) case .clearScrollCommentID: state.scrollCommentID = nil @@ -113,15 +113,15 @@ struct CommentsReducer: Reducer { case .performScrollOpacityEffect: return .merge( - Effect.publisher { + .publisher { Effect.send(.setScrollRowOpacity(0.25)) .delay(for: .milliseconds(750), scheduler: DispatchQueue.main) }, - Effect.publisher { + .publisher { Effect.send(.setScrollRowOpacity(1)) .delay(for: .milliseconds(1250), scheduler: DispatchQueue.main) }, - Effect.publisher { + .publisher { Effect.send(.clearScrollCommentID) .delay(for: .milliseconds(2000), scheduler: DispatchQueue.main) } @@ -134,18 +134,18 @@ struct CommentsReducer: Reducer { let (isGalleryImageURL, _, _) = urlClient.analyzeURL(url) let gid = urlClient.parseGalleryID(url) guard databaseClient.fetchGallery(gid: gid) == nil else { - return Effect.send(.handleGalleryLink(url)) + return .send(.handleGalleryLink(url)) } - return Effect.send(.fetchGallery(url, isGalleryImageURL)) + return .send(.fetchGallery(url, isGalleryImageURL)) case .handleGalleryLink(let url): let (_, pageIndex, commentID) = urlClient.analyzeURL(url) let gid = urlClient.parseGalleryID(url) var effects = [Effect]() if let pageIndex = pageIndex { - effects.append(Effect.send(.updateReadingProgress(gid, pageIndex))) + effects.append(.send(.updateReadingProgress(gid, pageIndex))) effects.append( - Effect.publisher { + .publisher { Effect.send(.detail(.setNavigation(.reading))) .delay(for: .milliseconds(750), scheduler: DispatchQueue.main) } @@ -153,17 +153,17 @@ struct CommentsReducer: Reducer { } else if let commentID = commentID { state.detailState.commentsState?.scrollCommentID = commentID effects.append( - Effect.publisher { + .publisher { Effect.send(.detail(.setNavigation(.comments(url)))) .delay(for: .milliseconds(750), scheduler: DispatchQueue.main) } ) } - effects.append(Effect.send(.setNavigation(.detail(gid)))) + effects.append(.send(.setNavigation(.detail(gid)))) return .merge(effects) case .onPostCommentAppear: - return Effect.publisher { + return .publisher { Effect.send(.setPostCommentFocused(true)) .delay(for: .milliseconds(750), scheduler: DispatchQueue.main) } @@ -221,7 +221,7 @@ struct CommentsReducer: Reducer { Effect.send(.handleGalleryLink(url)) ) case .failure: - return Effect.publisher { + return .publisher { Effect.send(.setHUDConfig(.error)) .delay(for: .milliseconds(500), scheduler: DispatchQueue.main) } diff --git a/EhPanda/View/Detail/Comments/CommentsView.swift b/EhPanda/View/Detail/Comments/CommentsView.swift index 7e6b6f7b..50cdd5a5 100644 --- a/EhPanda/View/Detail/Comments/CommentsView.swift +++ b/EhPanda/View/Detail/Comments/CommentsView.swift @@ -272,9 +272,7 @@ struct CommentsView_Previews: PreviewProvider { static var previews: some View { NavigationView { CommentsView( - store: .init(initialState: .init()) { - CommentsReducer() - }, + store: .init(initialState: .init(), reducer: CommentsReducer.init), gid: .init(), token: .init(), apiKey: .init(), diff --git a/EhPanda/View/Detail/DetailReducer.swift b/EhPanda/View/Detail/DetailReducer.swift index 1f6c6e9f..58b8bbdb 100644 --- a/EhPanda/View/Detail/DetailReducer.swift +++ b/EhPanda/View/Detail/DetailReducer.swift @@ -151,7 +151,7 @@ struct DetailReducer: Reducer { ) case .onPostCommentAppear: - return Effect.publisher { + return .publisher { Effect.send(.setPostCommentFocused(true)) .delay(for: .milliseconds(750), scheduler: DispatchQueue.main) } @@ -164,7 +164,7 @@ struct DetailReducer: Reducer { if state.commentsState == nil { state.commentsState = .init() } - return Effect.send(.fetchDatabaseInfos(gid)) + return .send(.fetchDatabaseInfos(gid)) case .toggleShowFullTitle: state.showsFullTitle.toggle() @@ -191,7 +191,7 @@ struct DetailReducer: Reducer { return .merge( Effect.send(.rateGallery), .run(operation: { _ in hapticsClient.generateFeedback(.soft) }), - Effect.publisher { + .publisher { Effect.send(.confirmRatingDone).delay(for: 1, scheduler: DispatchQueue.main) } ) @@ -249,7 +249,7 @@ struct DetailReducer: Reducer { state.galleryTags = galleryState.tags state.galleryPreviewURLs = galleryState.previewURLs state.galleryComments = galleryState.comments - return Effect.send(.fetchGalleryDetail) + return .send(.fetchGalleryDetail) case .fetchGalleryDetail: guard state.loadingState != .loading, @@ -276,13 +276,13 @@ struct DetailReducer: Reducer { state.galleryComments = galleryState.comments state.userRating = Int(galleryDetail.userRating) * 2 if let greeting = greeting { - effects.append(Effect.send(.syncGreeting(greeting))) + effects.append(.send(.syncGreeting(greeting))) if !greeting.gainedNothing && state.showsNewDawnGreeting { - effects.append(Effect.send(.setNavigation(.newDawn(greeting)))) + effects.append(.send(.setNavigation(.newDawn(greeting)))) } } if let config = galleryState.previewConfig { - effects.append(Effect.send(.syncPreviewConfig(config))) + effects.append(.send(.syncPreviewConfig(config))) } return .merge(effects) case .failure(let error): @@ -330,7 +330,7 @@ struct DetailReducer: Reducer { return .run(operation: { _ in hapticsClient.generateNotificationFeedback(.error) }) case .reading(.onPerformDismiss): - return Effect.send(.setNavigation(nil)) + return .send(.setNavigation(nil)) case .reading: return .none @@ -345,7 +345,7 @@ struct DetailReducer: Reducer { return .none case .comments(.performCommentActionDone(let result)): - return Effect.send(.anyGalleryOpsDone(result)) + return .send(.anyGalleryOpsDone(result)) case .comments(.detail(let recursiveAction)): guard state.commentsState != nil else { return .none } diff --git a/EhPanda/View/Detail/DetailSearch/DetailSearchReducer.swift b/EhPanda/View/Detail/DetailSearch/DetailSearchReducer.swift index e7c2d715..a25bde7e 100644 --- a/EhPanda/View/Detail/DetailSearch/DetailSearchReducer.swift +++ b/EhPanda/View/Detail/DetailSearch/DetailSearchReducer.swift @@ -116,7 +116,7 @@ struct DetailSearchReducer: Reducer { guard !galleries.isEmpty else { state.loadingState = .failed(.notFound) guard pageNumber.hasNextPage() else { return .none } - return Effect.send(.fetchMoreGalleries) + return .send(.fetchMoreGalleries) } state.pageNumber = pageNumber state.galleries = galleries @@ -149,7 +149,7 @@ struct DetailSearchReducer: Reducer { databaseClient.cacheGalleries(galleries).fireAndForget() ] if galleries.isEmpty, pageNumber.hasNextPage() { - effects.append(Effect.send(.fetchMoreGalleries)) + effects.append(.send(.fetchMoreGalleries)) } else if !galleries.isEmpty { state.loadingState = .idle } diff --git a/EhPanda/View/Detail/DetailSearch/DetailSearchView.swift b/EhPanda/View/Detail/DetailSearch/DetailSearchView.swift index 2a814386..aca88137 100644 --- a/EhPanda/View/Detail/DetailSearch/DetailSearchView.swift +++ b/EhPanda/View/Detail/DetailSearch/DetailSearchView.swift @@ -122,9 +122,7 @@ struct DetailSearchView: View { struct DetailSearchView_Previews: PreviewProvider { static var previews: some View { DetailSearchView( - store: .init(initialState: .init()) { - DetailSearchReducer() - }, + store: .init(initialState: .init(), reducer: DetailSearchReducer.init), keyword: .init(), user: .init(), setting: .constant(.init()), diff --git a/EhPanda/View/Detail/DetailView.swift b/EhPanda/View/Detail/DetailView.swift index 98da671b..ec601b2c 100644 --- a/EhPanda/View/Detail/DetailView.swift +++ b/EhPanda/View/Detail/DetailView.swift @@ -847,9 +847,7 @@ struct DetailView_Previews: PreviewProvider { static var previews: some View { NavigationView { DetailView( - store: .init(initialState: .init()) { - DetailReducer() - }, + store: .init(initialState: .init(), reducer: DetailReducer.init), gid: .init(), user: .init(), setting: .constant(.init()), diff --git a/EhPanda/View/Detail/GalleryInfos/GalleryInfosView.swift b/EhPanda/View/Detail/GalleryInfos/GalleryInfosView.swift index c98300f7..278dbae8 100644 --- a/EhPanda/View/Detail/GalleryInfos/GalleryInfosView.swift +++ b/EhPanda/View/Detail/GalleryInfos/GalleryInfosView.swift @@ -135,9 +135,7 @@ struct GalleryInfosView_Previews: PreviewProvider { static var previews: some View { NavigationView { GalleryInfosView( - store: .init(initialState: .init()) { - GalleryInfosReducer() - }, + store: .init(initialState: .init(), reducer: GalleryInfosReducer.init), gallery: .preview, galleryDetail: .preview ) diff --git a/EhPanda/View/Detail/Previews/PreviewsReducer.swift b/EhPanda/View/Detail/Previews/PreviewsReducer.swift index 4f509073..5fc9604f 100644 --- a/EhPanda/View/Detail/Previews/PreviewsReducer.swift +++ b/EhPanda/View/Detail/Previews/PreviewsReducer.swift @@ -73,7 +73,7 @@ struct PreviewsReducer: Reducer { case .clearSubStates: state.readingState = .init() - return Effect.send(.reading(.teardown)) + return .send(.reading(.teardown)) case .syncPreviewURLs(let previewURLs): return databaseClient @@ -119,14 +119,14 @@ struct PreviewsReducer: Reducer { return .none } state.updatePreviewURLs(previewURLs) - return Effect.send(.syncPreviewURLs(previewURLs)) + return .send(.syncPreviewURLs(previewURLs)) case .failure(let error): state.loadingState = .failed(error) } return .none case .reading(.onPerformDismiss): - return Effect.send(.setNavigation(nil)) + return .send(.setNavigation(nil)) case .reading: return .none diff --git a/EhPanda/View/Detail/Previews/PreviewsView.swift b/EhPanda/View/Detail/Previews/PreviewsView.swift index a20c3c0f..5fc13cb0 100644 --- a/EhPanda/View/Detail/Previews/PreviewsView.swift +++ b/EhPanda/View/Detail/Previews/PreviewsView.swift @@ -87,9 +87,7 @@ struct PreviewsView_Previews: PreviewProvider { static var previews: some View { NavigationView { PreviewsView( - store: .init(initialState: .init(gallery: .preview)) { - PreviewsReducer() - }, + store: .init(initialState: .init(gallery: .preview), reducer: PreviewsReducer.init), gid: .init(), setting: .constant(.init()), blurRadius: 0 diff --git a/EhPanda/View/Detail/Torrents/TorrentsReducer.swift b/EhPanda/View/Detail/Torrents/TorrentsReducer.swift index f0c8b16a..d50955b3 100644 --- a/EhPanda/View/Detail/Torrents/TorrentsReducer.swift +++ b/EhPanda/View/Detail/Torrents/TorrentsReducer.swift @@ -65,7 +65,7 @@ struct TorrentsReducer: Reducer { case .presentTorrentActivity(let hash, let data): if let url = fileClient.saveTorrent(hash: hash, data: data) { - return Effect.send(.setNavigation(.share(url))) + return .send(.setNavigation(.share(url))) } return .none @@ -78,7 +78,7 @@ struct TorrentsReducer: Reducer { case .fetchTorrentDone(let hash, let result): if case .success(let data) = result, !data.isEmpty { - return Effect.send(.presentTorrentActivity(hash, data)) + return .send(.presentTorrentActivity(hash, data)) } return .none diff --git a/EhPanda/View/Detail/Torrents/TorrentsView.swift b/EhPanda/View/Detail/Torrents/TorrentsView.swift index bac5a29c..6eab016e 100644 --- a/EhPanda/View/Detail/Torrents/TorrentsView.swift +++ b/EhPanda/View/Detail/Torrents/TorrentsView.swift @@ -118,9 +118,7 @@ private extension TorrentsView { struct TorrentsView_Previews: PreviewProvider { static var previews: some View { TorrentsView( - store: .init(initialState: .init()) { - TorrentsReducer() - }, + store: .init(initialState: .init(), reducer: TorrentsReducer.init), gid: .init(), token: .init(), blurRadius: 0 diff --git a/EhPanda/View/Favorites/FavoritesReducer.swift b/EhPanda/View/Favorites/FavoritesReducer.swift index 5e8a3f5d..310b4614 100644 --- a/EhPanda/View/Favorites/FavoritesReducer.swift +++ b/EhPanda/View/Favorites/FavoritesReducer.swift @@ -93,11 +93,11 @@ struct FavoritesReducer: Reducer { case .setFavoritesIndex(let index): state.index = index guard state.galleries?.isEmpty != false else { return .none } - return Effect.send(Action.fetchGalleries()) + return .send(Action.fetchGalleries()) case .clearSubStates: state.detailState = .init() - return Effect.send(.detail(.teardown)) + return .send(.detail(.teardown)) case .onNotLoginViewButtonTapped: return .none @@ -125,7 +125,7 @@ struct FavoritesReducer: Reducer { guard !galleries.isEmpty else { state.rawLoadingState[targetFavIndex] = .failed(.notFound) guard pageNumber.hasNextPage() else { return .none } - return Effect.send(.fetchMoreGalleries) + return .send(.fetchMoreGalleries) } state.rawPageNumber[targetFavIndex] = pageNumber state.rawGalleries[targetFavIndex] = galleries @@ -164,7 +164,7 @@ struct FavoritesReducer: Reducer { databaseClient.cacheGalleries(galleries).fireAndForget() ] if galleries.isEmpty, pageNumber.hasNextPage() { - effects.append(Effect.send(.fetchMoreGalleries)) + effects.append(.send(.fetchMoreGalleries)) } else if !galleries.isEmpty { state.rawLoadingState[targetFavIndex] = .idle } diff --git a/EhPanda/View/Favorites/FavoritesView.swift b/EhPanda/View/Favorites/FavoritesView.swift index 4772479a..4c1afaa0 100644 --- a/EhPanda/View/Favorites/FavoritesView.swift +++ b/EhPanda/View/Favorites/FavoritesView.swift @@ -135,9 +135,7 @@ struct FavoritesView: View { struct FavoritesView_Previews: PreviewProvider { static var previews: some View { FavoritesView( - store: .init(initialState: .init()) { - FavoritesReducer() - }, + store: .init(initialState: .init(), reducer: FavoritesReducer.init), user: .init(), setting: .constant(.init()), blurRadius: 0, diff --git a/EhPanda/View/Home/Frontpage/FrontpageReducer.swift b/EhPanda/View/Home/Frontpage/FrontpageReducer.swift index 39faaebc..0b08767a 100644 --- a/EhPanda/View/Home/Frontpage/FrontpageReducer.swift +++ b/EhPanda/View/Home/Frontpage/FrontpageReducer.swift @@ -82,7 +82,7 @@ struct FrontpageReducer: Reducer { case .clearSubStates: state.detailState = .init() state.filtersState = .init() - return Effect.send(.detail(.teardown)) + return .send(.detail(.teardown)) case .teardown: return .merge(CancelID.allCases.map(Effect.cancel(id:))) @@ -103,7 +103,7 @@ struct FrontpageReducer: Reducer { guard !galleries.isEmpty else { state.loadingState = .failed(.notFound) guard pageNumber.hasNextPage() else { return .none } - return Effect.send(.fetchMoreGalleries) + return .send(.fetchMoreGalleries) } state.pageNumber = pageNumber state.galleries = galleries @@ -136,7 +136,7 @@ struct FrontpageReducer: Reducer { databaseClient.cacheGalleries(galleries).fireAndForget() ] if galleries.isEmpty, pageNumber.hasNextPage() { - effects.append(Effect.send(.fetchMoreGalleries)) + effects.append(.send(.fetchMoreGalleries)) } else if !galleries.isEmpty { state.loadingState = .idle } diff --git a/EhPanda/View/Home/Frontpage/FrontpageView.swift b/EhPanda/View/Home/Frontpage/FrontpageView.swift index 228dddab..d9d651d7 100644 --- a/EhPanda/View/Home/Frontpage/FrontpageView.swift +++ b/EhPanda/View/Home/Frontpage/FrontpageView.swift @@ -98,9 +98,7 @@ struct FrontpageView_Previews: PreviewProvider { static var previews: some View { NavigationView { FrontpageView( - store: .init(initialState: .init()) { - FrontpageReducer() - }, + store: .init(initialState: .init(), reducer: FrontpageReducer.init), user: .init(), setting: .constant(.init()), blurRadius: 0, diff --git a/EhPanda/View/Home/History/HistoryReducer.swift b/EhPanda/View/Home/History/HistoryReducer.swift index 0da2bf44..e428b6dd 100644 --- a/EhPanda/View/Home/History/HistoryReducer.swift +++ b/EhPanda/View/Home/History/HistoryReducer.swift @@ -65,12 +65,12 @@ struct HistoryReducer: Reducer { case .clearSubStates: state.detailState = .init() - return Effect.send(.detail(.teardown)) + return .send(.detail(.teardown)) case .clearHistoryGalleries: return .merge( databaseClient.clearHistoryGalleries().fireAndForget(), - Effect.publisher { + .publisher { Effect.send(.fetchGalleries) .delay(for: .milliseconds(200), scheduler: DispatchQueue.main) } diff --git a/EhPanda/View/Home/History/HistoryView.swift b/EhPanda/View/Home/History/HistoryView.swift index e71bdb7d..df6632f5 100644 --- a/EhPanda/View/Home/History/HistoryView.swift +++ b/EhPanda/View/Home/History/HistoryView.swift @@ -104,9 +104,7 @@ struct HistoryView_Previews: PreviewProvider { static var previews: some View { NavigationView { HistoryView( - store: .init(initialState: .init()) { - HistoryReducer() - }, + store: .init(initialState: .init(), reducer: HistoryReducer.init), user: .init(), setting: .constant(.init()), blurRadius: 0, diff --git a/EhPanda/View/Home/HomeReducer.swift b/EhPanda/View/Home/HomeReducer.swift index 89a828fd..91577859 100644 --- a/EhPanda/View/Home/HomeReducer.swift +++ b/EhPanda/View/Home/HomeReducer.swift @@ -105,7 +105,7 @@ struct HomeReducer: Reducer { guard state.cardPageIndex < state.popularGalleries.count else { return .none } state.currentCardID = state.popularGalleries[state.cardPageIndex].gid state.allowsCardHitTesting = false - return Effect.publisher { + return .publisher { Effect.send(.setAllowsCardHitTesting(true)) .delay(for: .milliseconds(300), scheduler: DispatchQueue.main) } diff --git a/EhPanda/View/Home/HomeView.swift b/EhPanda/View/Home/HomeView.swift index b76beadc..1330ed72 100644 --- a/EhPanda/View/Home/HomeView.swift +++ b/EhPanda/View/Home/HomeView.swift @@ -519,9 +519,7 @@ enum HomeSectionType: String, CaseIterable, Identifiable { struct HomeView_Previews: PreviewProvider { static var previews: some View { HomeView( - store: .init(initialState: .init()) { - HomeReducer() - }, + store: .init(initialState: .init(), reducer: HomeReducer.init), user: .init(), setting: .constant(.init()), blurRadius: 0, diff --git a/EhPanda/View/Home/Popular/PopularReducer.swift b/EhPanda/View/Home/Popular/PopularReducer.swift index c8bbbff4..a82c101c 100644 --- a/EhPanda/View/Home/Popular/PopularReducer.swift +++ b/EhPanda/View/Home/Popular/PopularReducer.swift @@ -70,7 +70,7 @@ struct PopularReducer: Reducer { case .clearSubStates: state.detailState = .init() state.filtersState = .init() - return Effect.send(.detail(.teardown)) + return .send(.detail(.teardown)) case .teardown: return .cancel(id: CancelID.fetchGalleries) diff --git a/EhPanda/View/Home/Popular/PopularView.swift b/EhPanda/View/Home/Popular/PopularView.swift index 8541c235..220388d7 100644 --- a/EhPanda/View/Home/Popular/PopularView.swift +++ b/EhPanda/View/Home/Popular/PopularView.swift @@ -95,9 +95,7 @@ struct PopularView_Previews: PreviewProvider { static var previews: some View { NavigationView { PopularView( - store: .init(initialState: .init()) { - PopularReducer() - }, + store: .init(initialState: .init(), reducer: PopularReducer.init), user: .init(), setting: .constant(.init()), blurRadius: 0, diff --git a/EhPanda/View/Home/Toplists/ToplistsReducer.swift b/EhPanda/View/Home/Toplists/ToplistsReducer.swift index f8b6bb35..62419e36 100644 --- a/EhPanda/View/Home/Toplists/ToplistsReducer.swift +++ b/EhPanda/View/Home/Toplists/ToplistsReducer.swift @@ -109,11 +109,11 @@ struct ToplistsReducer: Reducer { case .setToplistsType(let type): state.type = type guard state.galleries?.isEmpty != false else { return .none } - return Effect.send(Action.fetchGalleries()) + return .send(Action.fetchGalleries()) case .clearSubStates: state.detailState = .init() - return Effect.send(.detail(.teardown)) + return .send(.detail(.teardown)) case .performJumpPage: guard let index = Int(state.jumpPageIndex), @@ -121,7 +121,7 @@ struct ToplistsReducer: Reducer { index > 0, index <= pageNumber.maximum + 1 else { return .run(operation: { _ in hapticsClient.generateNotificationFeedback(.error) }) } - return Effect.send(.fetchGalleries(index - 1)) + return .send(.fetchGalleries(index - 1)) case .presentJumpPageAlert: state.jumpPageAlertPresented = true @@ -153,7 +153,7 @@ struct ToplistsReducer: Reducer { guard !galleries.isEmpty else { state.rawLoadingState[type] = .failed(.notFound) guard pageNumber.hasNextPage() else { return .none } - return Effect.send(.fetchMoreGalleries) + return .send(.fetchMoreGalleries) } state.rawPageNumber[type] = pageNumber state.rawGalleries[type] = galleries @@ -185,7 +185,7 @@ struct ToplistsReducer: Reducer { databaseClient.cacheGalleries(galleries).fireAndForget() ] if galleries.isEmpty, pageNumber.hasNextPage() { - effects.append(Effect.send(.fetchMoreGalleries)) + effects.append(.send(.fetchMoreGalleries)) } else if !galleries.isEmpty { state.rawLoadingState[type] = .idle } diff --git a/EhPanda/View/Home/Toplists/ToplistsView.swift b/EhPanda/View/Home/Toplists/ToplistsView.swift index 13ee887e..a58f0bee 100644 --- a/EhPanda/View/Home/Toplists/ToplistsView.swift +++ b/EhPanda/View/Home/Toplists/ToplistsView.swift @@ -153,9 +153,7 @@ struct ToplistsView_Previews: PreviewProvider { static var previews: some View { NavigationView { ToplistsView( - store: .init(initialState: .init()) { - ToplistsReducer() - }, + store: .init(initialState: .init(), reducer: ToplistsReducer.init), user: .init(), setting: .constant(.init()), blurRadius: 0, diff --git a/EhPanda/View/Home/Watched/WatchedReducer.swift b/EhPanda/View/Home/Watched/WatchedReducer.swift index 47ad6972..b4a37f61 100644 --- a/EhPanda/View/Home/Watched/WatchedReducer.swift +++ b/EhPanda/View/Home/Watched/WatchedReducer.swift @@ -112,7 +112,7 @@ struct WatchedReducer: Reducer { guard !galleries.isEmpty else { state.loadingState = .failed(.notFound) guard pageNumber.hasNextPage() else { return .none } - return Effect.send(.fetchMoreGalleries) + return .send(.fetchMoreGalleries) } state.pageNumber = pageNumber state.galleries = galleries @@ -145,7 +145,7 @@ struct WatchedReducer: Reducer { databaseClient.cacheGalleries(galleries).fireAndForget() ] if galleries.isEmpty, pageNumber.hasNextPage() { - effects.append(Effect.send(.fetchMoreGalleries)) + effects.append(.send(.fetchMoreGalleries)) } else if !galleries.isEmpty { state.loadingState = .idle } diff --git a/EhPanda/View/Home/Watched/WatchedView.swift b/EhPanda/View/Home/Watched/WatchedView.swift index 912fff7d..16876b84 100644 --- a/EhPanda/View/Home/Watched/WatchedView.swift +++ b/EhPanda/View/Home/Watched/WatchedView.swift @@ -127,9 +127,7 @@ struct WatchedView_Previews: PreviewProvider { static var previews: some View { NavigationView { WatchedView( - store: .init(initialState: .init()) { - WatchedReducer() - }, + store: .init(initialState: .init(), reducer: WatchedReducer.init), user: .init(), setting: .constant(.init()), blurRadius: 0, diff --git a/EhPanda/View/Migration/MigrationReducer.swift b/EhPanda/View/Migration/MigrationReducer.swift index bc6a4e36..c66c91cf 100644 --- a/EhPanda/View/Migration/MigrationReducer.swift +++ b/EhPanda/View/Migration/MigrationReducer.swift @@ -55,12 +55,12 @@ struct MigrationReducer: Reducer { return .none } else { state.databaseState = .idle - return Effect.send(.onDatabasePreparationSuccess) + return .send(.onDatabasePreparationSuccess) } case .dropDatabase: state.databaseState = .loading - return Effect.publisher { + return .publisher { databaseClient.dropDatabase() .delay(for: .milliseconds(500), scheduler: DispatchQueue.main) .map(Action.dropDatabaseDone) @@ -72,7 +72,7 @@ struct MigrationReducer: Reducer { return .none } else { state.databaseState = .idle - return Effect.send(.onDatabasePreparationSuccess) + return .send(.onDatabasePreparationSuccess) } } } diff --git a/EhPanda/View/Migration/MigrationView.swift b/EhPanda/View/Migration/MigrationView.swift index 1261effd..ed316acf 100644 --- a/EhPanda/View/Migration/MigrationView.swift +++ b/EhPanda/View/Migration/MigrationView.swift @@ -53,10 +53,6 @@ struct MigrationView: View { struct MigrationView_Previews: PreviewProvider { static var previews: some View { - MigrationView( - store: .init(initialState: .init()) { - MigrationReducer() - } - ) + MigrationView(store: .init(initialState: .init(), reducer: MigrationReducer.init)) } } diff --git a/EhPanda/View/Reading/ReadingReducer.swift b/EhPanda/View/Reading/ReadingReducer.swift index 8edddd60..bb366e66 100644 --- a/EhPanda/View/Reading/ReadingReducer.swift +++ b/EhPanda/View/Reading/ReadingReducer.swift @@ -221,7 +221,7 @@ struct ReadingReducer: Reducer { Effect.send(.fetchDatabaseInfos(gid)) ] if enablesLandscape { - effects.append(Effect.send(.setOrientationPortrait(false))) + effects.append(.send(.setOrientationPortrait(false))) } return .merge(effects) @@ -263,17 +263,17 @@ struct ReadingReducer: Reducer { return .none case .copyImage(let imageURL): - return Effect.send(.fetchImage(.copy(imageURL.isGIF), imageURL)) + return .send(.fetchImage(.copy(imageURL.isGIF), imageURL)) case .saveImage(let imageURL): - return Effect.send(.fetchImage(.save(imageURL.isGIF), imageURL)) + return .send(.fetchImage(.save(imageURL.isGIF), imageURL)) case .saveImageDone(let isSucceeded): state.hudConfig = isSucceeded ? .savedToPhotoLibrary : .error - return Effect.send(.setNavigation(.hud)) + return .send(.setNavigation(.hud)) case .shareImage(let imageURL): - return Effect.send(.fetchImage(.share(imageURL.isGIF), imageURL)) + return .send(.fetchImage(.share(imageURL.isGIF), imageURL)) case .fetchImage(let action, let imageURL): return imageClient.fetchImage(url: imageURL) @@ -294,14 +294,14 @@ struct ReadingReducer: Reducer { .saveImageToPhotoLibrary(image, isAnimated).map(Action.saveImageDone) case .share(let isAnimated): if isAnimated, let data = image.kf.data(format: .GIF) { - return Effect.send(.setNavigation(.share(.data(data)))) + return .send(.setNavigation(.share(.data(data)))) } else { - return Effect.send(.setNavigation(.share(.image(image)))) + return .send(.setNavigation(.share(.image(image)))) } } } else { state.hudConfig = .error - return Effect.send(.setNavigation(.hud)) + return .send(.setNavigation(.hud)) } case .syncReadingProgress(let progress): @@ -326,7 +326,7 @@ struct ReadingReducer: Reducer { .merge(CancelID.allCases.map(Effect.cancel(id:))) ] if !deviceClient.isPad() { - effects.append(Effect.send(.setOrientationPortrait(true))) + effects.append(.send(.setOrientationPortrait(true))) } return .merge(effects) @@ -367,7 +367,7 @@ struct ReadingReducer: Reducer { } state.previewLoadingStates[index] = .idle state.updatePreviewURLs(previewURLs) - return Effect.send(.syncPreviewURLs(previewURLs)) + return .send(.syncPreviewURLs(previewURLs)) case .failure(let error): state.previewLoadingStates[index] = .failed(error) } @@ -375,16 +375,16 @@ struct ReadingReducer: Reducer { case .fetchImageURLs(let index): if state.mpvKey != nil { - return Effect.send(.fetchMPVImageURL(index, false)) + return .send(.fetchMPVImageURL(index, false)) } else { - return Effect.send(.fetchThumbnailURLs(index)) + return .send(.fetchThumbnailURLs(index)) } case .refetchImageURLs(let index): if state.mpvKey != nil { - return Effect.send(.fetchMPVImageURL(index, true)) + return .send(.fetchMPVImageURL(index, true)) } else { - return Effect.send(.refetchNormalImageURLs(index)) + return .send(.refetchNormalImageURLs(index)) } case .prefetchImages(let index, let prefetchLimit): @@ -420,7 +420,7 @@ struct ReadingReducer: Reducer { fetchImageURLIndices += getFetchImageURLIndices(range: nextLowerBound...nextUpperBound) } fetchImageURLIndices.forEach { - effects.append(Effect.send(.fetchImageURLs($0))) + effects.append(.send(.fetchImageURLs($0))) } effects.append(imageClient.prefetchImages(prefetchImageURLs).fireAndForget()) return .merge(effects) @@ -448,7 +448,7 @@ struct ReadingReducer: Reducer { return .none } if let url = thumbnailURLs[index], urlClient.checkIfMPVURL(url) { - return Effect.send(.fetchMPVKeys(index, url)) + return .send(.fetchMPVKeys(index, url)) } else { state.updateThumbnailURLs(thumbnailURLs) return .merge( @@ -482,7 +482,7 @@ struct ReadingReducer: Reducer { state.imageURLLoadingStates[$0] = .idle } state.updateImageURLs(imageURLs, originalImageURLs) - return Effect.send(.syncImageURLs(imageURLs, originalImageURLs)) + return .send(.syncImageURLs(imageURLs, originalImageURLs)) case .failure(let error): batchRange.forEach { state.imageURLLoadingStates[$0] = .failed(error) @@ -519,7 +519,7 @@ struct ReadingReducer: Reducer { } state.imageURLLoadingStates[index] = .idle state.updateImageURLs(imageURLs, [:]) - effects.append(Effect.send(.syncImageURLs(imageURLs, [:]))) + effects.append(.send(.syncImageURLs(imageURLs, [:]))) return .merge(effects) case .failure(let error): state.imageURLLoadingStates[index] = .failed(error) @@ -582,7 +582,7 @@ struct ReadingReducer: Reducer { state.imageURLLoadingStates[index] = .idle state.mpvSkipServerIdentifiers[index] = skipServerIdentifier state.updateImageURLs(imageURLs, originalImageURLs) - return Effect.send(.syncImageURLs(imageURLs, originalImageURLs)) + return .send(.syncImageURLs(imageURLs, originalImageURLs)) case .failure(let error): state.imageURLLoadingStates[index] = .failed(error) } diff --git a/EhPanda/View/Reading/ReadingView.swift b/EhPanda/View/Reading/ReadingView.swift index 1087c887..00bae5c8 100644 --- a/EhPanda/View/Reading/ReadingView.swift +++ b/EhPanda/View/Reading/ReadingView.swift @@ -598,9 +598,7 @@ struct ReadingView_Previews: PreviewProvider { Text("") .fullScreenCover(isPresented: .constant(true)) { ReadingView( - store: .init(initialState: .init(gallery: .empty)) { - ReadingReducer() - }, + store: .init(initialState: .init(gallery: .empty), reducer: ReadingReducer.init), gid: .init(), setting: .constant(.init()), blurRadius: 0 diff --git a/EhPanda/View/Search/SearchReducer.swift b/EhPanda/View/Search/SearchReducer.swift index c4438d58..d6e603d0 100644 --- a/EhPanda/View/Search/SearchReducer.swift +++ b/EhPanda/View/Search/SearchReducer.swift @@ -117,7 +117,7 @@ struct SearchReducer: Reducer { guard !galleries.isEmpty else { state.loadingState = .failed(.notFound) guard pageNumber.hasNextPage() else { return .none } - return Effect.send(.fetchMoreGalleries) + return .send(.fetchMoreGalleries) } state.pageNumber = pageNumber state.galleries = galleries @@ -150,7 +150,7 @@ struct SearchReducer: Reducer { databaseClient.cacheGalleries(galleries).fireAndForget() ] if galleries.isEmpty, pageNumber.hasNextPage() { - effects.append(Effect.send(.fetchMoreGalleries)) + effects.append(.send(.fetchMoreGalleries)) } else if !galleries.isEmpty { state.loadingState = .idle } diff --git a/EhPanda/View/Search/SearchRootReducer.swift b/EhPanda/View/Search/SearchRootReducer.swift index cf707e42..9add5e85 100644 --- a/EhPanda/View/Search/SearchRootReducer.swift +++ b/EhPanda/View/Search/SearchRootReducer.swift @@ -139,11 +139,11 @@ struct SearchRootReducer: Reducer { case .appendHistoryKeyword(let keyword): state.appendHistoryKeywords([keyword]) - return Effect.send(.syncHistoryKeywords) + return .send(.syncHistoryKeywords) case .removeHistoryKeyword(let keyword): state.removeHistoryKeyword(keyword) - return Effect.send(.syncHistoryKeywords) + return .send(.syncHistoryKeywords) case .fetchHistoryGalleries: return databaseClient.fetchHistoryGalleries(fetchLimit: 10).map(Action.fetchHistoryGalleriesDone) @@ -158,7 +158,7 @@ struct SearchRootReducer: Reducer { } else { state.appendHistoryKeywords([state.searchState.lastKeyword]) } - return Effect.send(.syncHistoryKeywords) + return .send(.syncHistoryKeywords) case .search: return .none diff --git a/EhPanda/View/Search/SearchRootView.swift b/EhPanda/View/Search/SearchRootView.swift index 2f7db5c8..89d8bc70 100644 --- a/EhPanda/View/Search/SearchRootView.swift +++ b/EhPanda/View/Search/SearchRootView.swift @@ -404,9 +404,7 @@ private struct WrappedKeyword: Hashable { struct SearchRootView_Previews: PreviewProvider { static var previews: some View { SearchRootView( - store: .init(initialState: .init()) { - SearchRootReducer() - }, + store: .init(initialState: .init(), reducer: SearchRootReducer.init), user: .init(), setting: .constant(.init()), blurRadius: 0, diff --git a/EhPanda/View/Search/SearchView.swift b/EhPanda/View/Search/SearchView.swift index a2623f04..e78a70b2 100644 --- a/EhPanda/View/Search/SearchView.swift +++ b/EhPanda/View/Search/SearchView.swift @@ -122,9 +122,7 @@ struct SearchView: View { struct SearchView_Previews: PreviewProvider { static var previews: some View { SearchView( - store: .init(initialState: .init()) { - SearchReducer() - }, + store: .init(initialState: .init(), reducer: SearchReducer.init), keyword: .init(), user: .init(), setting: .constant(.init()), diff --git a/EhPanda/View/Search/Support/QuickSearchReducer.swift b/EhPanda/View/Search/Support/QuickSearchReducer.swift index aad8e868..6745df14 100644 --- a/EhPanda/View/Search/Support/QuickSearchReducer.swift +++ b/EhPanda/View/Search/Support/QuickSearchReducer.swift @@ -94,26 +94,26 @@ struct QuickSearchReducer: Reducer { case .appendWord: state.quickSearchWords.append(state.editingWord) - return Effect.send(.syncQuickSearchWords) + return .send(.syncQuickSearchWords) case .editWord: if let index = state.quickSearchWords.firstIndex(where: { $0.id == state.editingWord.id }) { state.quickSearchWords[index] = state.editingWord - return Effect.send(.syncQuickSearchWords) + return .send(.syncQuickSearchWords) } return .none case .deleteWord(let word): state.quickSearchWords = state.quickSearchWords.filter({ $0 != word }) - return Effect.send(.syncQuickSearchWords) + return .send(.syncQuickSearchWords) case .deleteWordWithOffsets(let offsets): state.quickSearchWords.remove(atOffsets: offsets) - return Effect.send(.syncQuickSearchWords) + return .send(.syncQuickSearchWords) case .moveWord(let source, let destination): state.quickSearchWords.move(fromOffsets: source, toOffset: destination) - return Effect.send(.syncQuickSearchWords) + return .send(.syncQuickSearchWords) case .teardown: return .cancel(id: CancelID.fetchQuickSearchWords) diff --git a/EhPanda/View/Search/Support/QuickSearchView.swift b/EhPanda/View/Search/Support/QuickSearchView.swift index 11046ef3..605c548d 100644 --- a/EhPanda/View/Search/Support/QuickSearchView.swift +++ b/EhPanda/View/Search/Support/QuickSearchView.swift @@ -202,9 +202,7 @@ extension QuickSearchView { struct QuickSearchView_Previews: PreviewProvider { static var previews: some View { QuickSearchView( - store: .init(initialState: .init()) { - QuickSearchReducer() - }, + store: .init(initialState: .init(), reducer: QuickSearchReducer.init), searchAction: { _ in } ) } diff --git a/EhPanda/View/Setting/AccountSetting/AccountSettingView.swift b/EhPanda/View/Setting/AccountSetting/AccountSettingView.swift index 17676ab3..de1606a4 100644 --- a/EhPanda/View/Setting/AccountSetting/AccountSettingView.swift +++ b/EhPanda/View/Setting/AccountSetting/AccountSettingView.swift @@ -222,9 +222,7 @@ struct AccountSettingView_Previews: PreviewProvider { static var previews: some View { NavigationView { AccountSettingView( - store: .init(initialState: .init()) { - AccountSettingReducer() - }, + store: .init(initialState: .init(), reducer: AccountSettingReducer.init), galleryHost: .constant(.ehentai), showsNewDawnGreeting: .constant(false), bypassesSNIFiltering: false, diff --git a/EhPanda/View/Setting/AppearanceSetting/AppearanceSettingView.swift b/EhPanda/View/Setting/AppearanceSetting/AppearanceSettingView.swift index a1b5d248..4d1ee0cc 100644 --- a/EhPanda/View/Setting/AppearanceSetting/AppearanceSettingView.swift +++ b/EhPanda/View/Setting/AppearanceSetting/AppearanceSettingView.swift @@ -228,9 +228,7 @@ struct AppearanceSettingView_Previews: PreviewProvider { static var previews: some View { NavigationView { AppearanceSettingView( - store: .init(initialState: .init()) { - AppearanceSettingReducer() - }, + store: .init(initialState: .init(), reducer: AppearanceSettingReducer.init), preferredColorScheme: .constant(.automatic), accentColor: .constant(.blue), appIconType: .constant(.default), diff --git a/EhPanda/View/Setting/EhSetting/EhSettingView.swift b/EhPanda/View/Setting/EhSetting/EhSettingView.swift index 01d8f0e2..ff1c0540 100644 --- a/EhPanda/View/Setting/EhSetting/EhSettingView.swift +++ b/EhPanda/View/Setting/EhSetting/EhSettingView.swift @@ -1019,9 +1019,10 @@ struct EhSettingView_Previews: PreviewProvider { static var previews: some View { NavigationView { EhSettingView( - store: .init(initialState: .init(ehSetting: .empty, ehProfile: .empty, loadingState: .idle)) { - EhSettingReducer() - }, + store: .init( + initialState: .init(ehSetting: .empty, ehProfile: .empty, loadingState: .idle), + reducer: EhSettingReducer.init + ), bypassesSNIFiltering: false, blurRadius: 0 ) diff --git a/EhPanda/View/Setting/GeneralSetting/GeneralSettingReducer.swift b/EhPanda/View/Setting/GeneralSetting/GeneralSettingReducer.swift index 7e9ca7e5..877f5b52 100644 --- a/EhPanda/View/Setting/GeneralSetting/GeneralSettingReducer.swift +++ b/EhPanda/View/Setting/GeneralSetting/GeneralSettingReducer.swift @@ -64,7 +64,7 @@ struct GeneralSettingReducer: Reducer { case .clearSubStates: state.logsState = .init() - return Effect.send(.logs(.teardown)) + return .send(.logs(.teardown)) case .onTranslationsFilePicked: return .none diff --git a/EhPanda/View/Setting/GeneralSetting/GeneralSettingView.swift b/EhPanda/View/Setting/GeneralSetting/GeneralSettingView.swift index 57e604bf..3b5bb09c 100644 --- a/EhPanda/View/Setting/GeneralSetting/GeneralSettingView.swift +++ b/EhPanda/View/Setting/GeneralSetting/GeneralSettingView.swift @@ -196,9 +196,7 @@ struct GeneralSettingView_Previews: PreviewProvider { static var previews: some View { NavigationView { GeneralSettingView( - store: .init(initialState: .init()) { - GeneralSettingReducer() - }, + store: .init(initialState: .init(), reducer: GeneralSettingReducer.init), tagTranslatorLoadingState: .idle, tagTranslatorEmpty: false, tagTranslatorHasCustomTranslations: false, diff --git a/EhPanda/View/Setting/Login/LoginView.swift b/EhPanda/View/Setting/Login/LoginView.swift index fb4d98b8..9a300d58 100644 --- a/EhPanda/View/Setting/Login/LoginView.swift +++ b/EhPanda/View/Setting/Login/LoginView.swift @@ -134,9 +134,7 @@ struct LoginView_Previews: PreviewProvider { static var previews: some View { NavigationView { LoginView( - store: .init(initialState: .init()) { - LoginReducer() - }, + store: .init(initialState: .init(), reducer: LoginReducer.init), bypassesSNIFiltering: false, blurRadius: 0 ) diff --git a/EhPanda/View/Setting/Logs/LogsView.swift b/EhPanda/View/Setting/Logs/LogsView.swift index f244d57c..7ab24546 100644 --- a/EhPanda/View/Setting/Logs/LogsView.swift +++ b/EhPanda/View/Setting/Logs/LogsView.swift @@ -174,11 +174,7 @@ extension Log: CustomStringConvertible { struct LogsView_Previews: PreviewProvider { static var previews: some View { NavigationView { - LogsView( - store: .init(initialState: .init()) { - LogsReducer() - } - ) + LogsView(store: .init(initialState: .init(), reducer: LogsReducer.init)) } } } diff --git a/EhPanda/View/Setting/SettingReducer.swift b/EhPanda/View/Setting/SettingReducer.swift index c398aaeb..91896609 100644 --- a/EhPanda/View/Setting/SettingReducer.swift +++ b/EhPanda/View/Setting/SettingReducer.swift @@ -126,7 +126,7 @@ struct SettingReducer: Reducer { Effect.send(.syncSetting) ] if state.setting.enablesTagsExtension { - effects.append(Effect.send(.fetchTagTranslator)) + effects.append(.send(.fetchTagTranslator)) } return .merge(effects) @@ -149,7 +149,7 @@ struct SettingReducer: Reducer { { state.setting.backgroundBlurRadius = 10 } - return Effect.send(.syncSetting) + return .send(.syncSetting) case .binding(\.$setting.backgroundBlurRadius): if state.setting.autoLockPolicy != .never @@ -157,7 +157,7 @@ struct SettingReducer: Reducer { { state.setting.autoLockPolicy = .never } - return Effect.send(.syncSetting) + return .send(.syncSetting) case .binding(\.$setting.enablesLandscape): var effects: [Effect] = [ @@ -172,13 +172,13 @@ struct SettingReducer: Reducer { if state.setting.doubleTapScaleFactor > state.setting.maximumScaleFactor { state.setting.doubleTapScaleFactor = state.setting.maximumScaleFactor } - return Effect.send(.syncSetting) + return .send(.syncSetting) case .binding(\.$setting.doubleTapScaleFactor): if state.setting.maximumScaleFactor < state.setting.doubleTapScaleFactor { state.setting.maximumScaleFactor = state.setting.doubleTapScaleFactor } - return Effect.send(.syncSetting) + return .send(.syncSetting) case .binding(\.$setting.bypassesSNIFiltering): return .merge( @@ -188,7 +188,7 @@ struct SettingReducer: Reducer { ) case .binding(\.$setting): - return Effect.send(.syncSetting) + return .send(.syncSetting) case .binding(\.$route): return .none @@ -249,7 +249,7 @@ struct SettingReducer: Reducer { state.setting.galleryHost = galleryHost } if cookieClient.shouldFetchIgneous { - effects.append(Effect.send(.fetchIgneous)) + effects.append(.send(.fetchIgneous)) } if cookieClient.didLogin { effects.append(contentsOf: [ @@ -260,7 +260,7 @@ struct SettingReducer: Reducer { ]) } if state.setting.enablesTagsExtension { - effects.append(Effect.send(.fetchTagTranslator)) + effects.append(.send(.fetchTagTranslator)) } return .merge(effects) @@ -280,7 +280,7 @@ struct SettingReducer: Reducer { if case .success(let response) = result { effects.append(cookieClient.setCredentials(response: response).fireAndForget()) } - effects.append(Effect.send(.account(.loadCookies))) + effects.append(.send(.account(.loadCookies))) return .merge(effects) case .fetchUserInfo: @@ -295,7 +295,7 @@ struct SettingReducer: Reducer { case .fetchUserInfoDone(let result): if case .success(let user) = result { state.updateUser(user) - return Effect.send(.syncUser) + return .send(.syncUser) } return .none @@ -335,13 +335,13 @@ struct SettingReducer: Reducer { switch result { case .success(let greeting): state.setGreeting(greeting) - return Effect.send(.syncUser) + return .send(.syncUser) case .failure(let error): if case .parseFailed = error { var greeting = Greeting() greeting.updateTime = Date() state.setGreeting(greeting) - return Effect.send(.syncUser) + return .send(.syncUser) } } return .none @@ -372,7 +372,7 @@ struct SettingReducer: Reducer { switch result { case .success(let tagTranslator): state.tagTranslator = tagTranslator - return Effect.send(.syncTagTranslator) + return .send(.syncTagTranslator) case .failure(let error): state.tagTranslatorLoadingState = .failed(error) } @@ -401,7 +401,7 @@ struct SettingReducer: Reducer { ) } } else if response.isProfileNotFound { - effects.append(Effect.send(.createDefaultEhProfile)) + effects.append(.send(.createDefaultEhProfile)) } else { let message = "Found profile but failed in parsing value." effects.append(loggerClient.error(message, nil).fireAndForget()) @@ -448,7 +448,7 @@ struct SettingReducer: Reducer { case .general(.onRemoveCustomTranslations): state.tagTranslator.hasCustomTranslations = false state.tagTranslator.translations = .init() - return Effect.send(.syncTagTranslator) + return .send(.syncTagTranslator) case .general: return .none diff --git a/EhPanda/View/Setting/SettingView.swift b/EhPanda/View/Setting/SettingView.swift index 95c9d16e..9a77b565 100644 --- a/EhPanda/View/Setting/SettingView.swift +++ b/EhPanda/View/Setting/SettingView.swift @@ -183,9 +183,7 @@ extension SettingReducer.Route { struct SettingView_Previews: PreviewProvider { static var previews: some View { SettingView( - store: .init(initialState: .init()) { - SettingReducer() - }, + store: .init(initialState: .init(), reducer: SettingReducer.init), blurRadius: 0 ) } diff --git a/EhPanda/View/Support/FiltersReducer.swift b/EhPanda/View/Support/FiltersReducer.swift index 16a70d98..319efd99 100644 --- a/EhPanda/View/Support/FiltersReducer.swift +++ b/EhPanda/View/Support/FiltersReducer.swift @@ -47,15 +47,15 @@ struct FiltersReducer: Reducer { switch action { case .binding(\.$searchFilter): state.searchFilter.fixInvalidData() - return Effect.send(.syncFilter(.search)) + return .send(.syncFilter(.search)) case .binding(\.$globalFilter): state.globalFilter.fixInvalidData() - return Effect.send(.syncFilter(.global)) + return .send(.syncFilter(.global)) case .binding(\.$watchedFilter): state.watchedFilter.fixInvalidData() - return Effect.send(.syncFilter(.watched)) + return .send(.syncFilter(.watched)) case .binding: return .none @@ -91,13 +91,13 @@ struct FiltersReducer: Reducer { switch state.filterRange { case .search: state.searchFilter = .init() - return Effect.send(.syncFilter(.search)) + return .send(.syncFilter(.search)) case .global: state.globalFilter = .init() - return Effect.send(.syncFilter(.global)) + return .send(.syncFilter(.global)) case .watched: state.watchedFilter = .init() - return Effect.send(.syncFilter(.watched)) + return .send(.syncFilter(.watched)) } case .fetchFilters: diff --git a/EhPanda/View/Support/FiltersView.swift b/EhPanda/View/Support/FiltersView.swift index cc4f8f75..c7dc475a 100644 --- a/EhPanda/View/Support/FiltersView.swift +++ b/EhPanda/View/Support/FiltersView.swift @@ -239,10 +239,6 @@ extension FilterRange { struct FiltersView_Previews: PreviewProvider { static var previews: some View { - FiltersView( - store: .init(initialState: .init()) { - FiltersReducer() - } - ) + FiltersView(store: .init(initialState: .init(), reducer: FiltersReducer.init)) } } diff --git a/EhPanda/View/TabBar/TabBarView.swift b/EhPanda/View/TabBar/TabBarView.swift index b48f06b9..9817779a 100644 --- a/EhPanda/View/TabBar/TabBarView.swift +++ b/EhPanda/View/TabBar/TabBarView.swift @@ -155,10 +155,6 @@ extension TabBarItemType { struct TabBarView_Previews: PreviewProvider { static var previews: some View { - TabBarView( - store: .init(initialState: .init()) { - AppReducer() - } - ) + TabBarView(store: .init(initialState: .init(), reducer: AppReducer.init)) } }