From dfb90d5dfce03e05d515197b1cc6242b73de93af Mon Sep 17 00:00:00 2001 From: Chihchy Date: Thu, 30 May 2024 20:49:25 +0800 Subject: [PATCH] Resolve warnings & enforce code style --- .swiftlint.yml | 1 + EhPanda/DataFlow/AppRouteReducer.swift | 5 ++++- EhPanda/Models/Tags/TagDetail.swift | 7 ------- .../View/Detail/Archives/ArchivesReducer.swift | 3 ++- .../View/Detail/Comments/CommentsReducer.swift | 16 ++++++++++++---- EhPanda/View/Detail/DetailReducer.swift | 14 ++++++++++---- .../DetailSearch/DetailSearchReducer.swift | 5 ++++- EhPanda/View/Favorites/FavoritesReducer.swift | 6 ++++-- EhPanda/View/Home/Toplists/ToplistsReducer.swift | 10 ++++++++-- EhPanda/View/Home/Watched/WatchedReducer.swift | 5 ++++- EhPanda/View/Reading/ReadingReducer.swift | 6 ++++-- EhPanda/View/Search/SearchReducer.swift | 5 ++++- 12 files changed, 57 insertions(+), 26 deletions(-) diff --git a/.swiftlint.yml b/.swiftlint.yml index 22adb80e..65bd698e 100644 --- a/.swiftlint.yml +++ b/.swiftlint.yml @@ -15,3 +15,4 @@ identifier_name: excluded: - EhPandaTests + - EhPanda/App/Generated diff --git a/EhPanda/DataFlow/AppRouteReducer.swift b/EhPanda/DataFlow/AppRouteReducer.swift index e8b41369..8089da8e 100644 --- a/EhPanda/DataFlow/AppRouteReducer.swift +++ b/EhPanda/DataFlow/AppRouteReducer.swift @@ -147,7 +147,10 @@ struct AppRouteReducer: Reducer { case .fetchGallery(let url, let isGalleryImageURL): state.route = .hud return .run { send in - let response = await GalleryReverseRequest(url: url, isGalleryImageURL: isGalleryImageURL).response() + let response = await GalleryReverseRequest( + url: url, isGalleryImageURL: isGalleryImageURL + ) + .response() await send(Action.fetchGalleryDone(url, response)) } diff --git a/EhPanda/Models/Tags/TagDetail.swift b/EhPanda/Models/Tags/TagDetail.swift index 3300a0ee..fb7a13c9 100644 --- a/EhPanda/Models/Tags/TagDetail.swift +++ b/EhPanda/Models/Tags/TagDetail.swift @@ -12,11 +12,4 @@ struct TagDetail: Equatable { let description: String let imageURLs: [URL] let links: [URL] - - init(title: String, description: String, imageURLs: [URL], links: [URL]) { - self.title = title - self.description = description - self.imageURLs = imageURLs - self.links = links - } } diff --git a/EhPanda/View/Detail/Archives/ArchivesReducer.swift b/EhPanda/View/Detail/Archives/ArchivesReducer.swift index 6c7a7510..47ef4693 100644 --- a/EhPanda/View/Detail/Archives/ArchivesReducer.swift +++ b/EhPanda/View/Detail/Archives/ArchivesReducer.swift @@ -122,7 +122,8 @@ struct ArchivesReducer: Reducer { let response = await SendDownloadCommandRequest( archiveURL: archiveURL, resolution: selectedArchive.resolution.parameter - ).response() + ) + .response() await send(Action.fetchDownloadResponseDone(response)) } .cancellable(id: CancelID.fetchDownloadResponse) diff --git a/EhPanda/View/Detail/Comments/CommentsReducer.swift b/EhPanda/View/Detail/Comments/CommentsReducer.swift index 963b6935..25232e32 100644 --- a/EhPanda/View/Detail/Comments/CommentsReducer.swift +++ b/EhPanda/View/Detail/Comments/CommentsReducer.swift @@ -193,13 +193,17 @@ struct CommentsReducer: Reducer { commentID: commentID, content: commentContent, galleryURL: galleryURL - ).response() + ) + .response() await send(Action.performCommentActionDone(response)) } .cancellable(id: CancelID.postComment) } else { return .run { [commentContent = state.commentContent] send in - let response = await CommentGalleryRequest(content: commentContent, galleryURL: galleryURL).response() + let response = await CommentGalleryRequest( + content: commentContent, galleryURL: galleryURL + ) + .response() await send(Action.performCommentActionDone(response)) } .cancellable(id: CancelID.postComment) @@ -217,7 +221,8 @@ struct CommentsReducer: Reducer { token: token, commentID: commentID, commentVote: vote - ).response() + ) + .response() await send(Action.performCommentActionDone(response)) } .cancellable(id: CancelID.voteComment) @@ -228,7 +233,10 @@ struct CommentsReducer: Reducer { case .fetchGallery(let url, let isGalleryImageURL): state.route = .hud return .run { send in - let response = await GalleryReverseRequest(url: url, isGalleryImageURL: isGalleryImageURL).response() + let response = await GalleryReverseRequest( + url: url, isGalleryImageURL: isGalleryImageURL + ) + .response() await send(Action.fetchGalleryDone(url, response)) } .cancellable(id: CancelID.fetchGallery) diff --git a/EhPanda/View/Detail/DetailReducer.swift b/EhPanda/View/Detail/DetailReducer.swift index cf699d6c..21c230a6 100644 --- a/EhPanda/View/Detail/DetailReducer.swift +++ b/EhPanda/View/Detail/DetailReducer.swift @@ -325,7 +325,8 @@ struct DetailReducer: Reducer { gid: gid, token: state.gallery.token, rating: state.userRating - ).response() + ) + .response() await send(Action.anyGalleryOpsDone(response)) }.cancellable(id: CancelID.rateGallery) @@ -335,7 +336,8 @@ struct DetailReducer: Reducer { gid: state.gallery.id, token: state.gallery.token, favIndex: favIndex - ).response() + ) + .response() await send(Action.anyGalleryOpsDone(response)) } .cancellable(id: CancelID.favorGallery) @@ -350,7 +352,10 @@ struct DetailReducer: Reducer { case .postComment(let galleryURL): guard !state.commentContent.isEmpty else { return .none } return .run { [commentContent = state.commentContent] send in - let response = await CommentGalleryRequest(content: commentContent, galleryURL: galleryURL).response() + let response = await CommentGalleryRequest( + content: commentContent, galleryURL: galleryURL + ) + .response() await send(Action.anyGalleryOpsDone(response)) } .cancellable(id: CancelID.postComment) @@ -366,7 +371,8 @@ struct DetailReducer: Reducer { token: state.gallery.token, tag: tag, vote: vote - ).response() + ) + .response() await send(Action.anyGalleryOpsDone(response)) } .cancellable(id: CancelID.voteTag) diff --git a/EhPanda/View/Detail/DetailSearch/DetailSearchReducer.swift b/EhPanda/View/Detail/DetailSearch/DetailSearchReducer.swift index 0552db23..dd47d375 100644 --- a/EhPanda/View/Detail/DetailSearch/DetailSearchReducer.swift +++ b/EhPanda/View/Detail/DetailSearch/DetailSearchReducer.swift @@ -140,7 +140,10 @@ struct DetailSearchReducer: Reducer { state.footerLoadingState = .loading let filter = databaseClient.fetchFilterSynchronously(range: .search) return .run { [lastKeyword = state.lastKeyword] send in - let response = await MoreSearchGalleriesRequest(keyword: lastKeyword, filter: filter, lastID: lastID).response() + let response = await MoreSearchGalleriesRequest( + keyword: lastKeyword, filter: filter, lastID: lastID + ) + .response() await send(Action.fetchMoreGalleriesDone(response)) } .cancellable(id: CancelID.fetchMoreGalleries) diff --git a/EhPanda/View/Favorites/FavoritesReducer.swift b/EhPanda/View/Favorites/FavoritesReducer.swift index e2829885..14669cdf 100644 --- a/EhPanda/View/Favorites/FavoritesReducer.swift +++ b/EhPanda/View/Favorites/FavoritesReducer.swift @@ -116,7 +116,8 @@ struct FavoritesReducer: Reducer { return .run { [state] send in let response = await FavoritesGalleriesRequest( favIndex: state.index, keyword: state.keyword, sortOrder: sortOrder - ).response() + ) + .response() await send(Action.fetchGalleriesDone(state.index, response)) } @@ -154,7 +155,8 @@ struct FavoritesReducer: Reducer { lastID: lastID, lastTimestamp: lastItemTimestamp, keyword: state.keyword - ).response() + ) + .response() await send(Action.fetchMoreGalleriesDone(state.index, response)) } diff --git a/EhPanda/View/Home/Toplists/ToplistsReducer.swift b/EhPanda/View/Home/Toplists/ToplistsReducer.swift index 7cca9ac7..04b906e6 100644 --- a/EhPanda/View/Home/Toplists/ToplistsReducer.swift +++ b/EhPanda/View/Home/Toplists/ToplistsReducer.swift @@ -147,7 +147,10 @@ struct ToplistsReducer: Reducer { state.rawPageNumber[state.type]?.resetPages() } return .run { [type = state.type] send in - let response = await ToplistsGalleriesRequest(catIndex: type.categoryIndex, pageNum: pageNum).response() + let response = await ToplistsGalleriesRequest( + catIndex: type.categoryIndex, pageNum: pageNum + ) + .response() await send(Action.fetchGalleriesDone(type, response)) } .cancellable(id: CancelID.fetchGalleries) @@ -179,7 +182,10 @@ struct ToplistsReducer: Reducer { state.rawFooterLoadingState[state.type] = .loading let pageNum = pageNumber.current + 1 return .run { [type = state.type] send in - let response = await MoreToplistsGalleriesRequest(catIndex: type.categoryIndex, pageNum: pageNum).response() + let response = await MoreToplistsGalleriesRequest( + catIndex: type.categoryIndex, pageNum: pageNum + ) + .response() await send(Action.fetchMoreGalleriesDone(type, response)) } .cancellable(id: CancelID.fetchMoreGalleries) diff --git a/EhPanda/View/Home/Watched/WatchedReducer.swift b/EhPanda/View/Home/Watched/WatchedReducer.swift index 35407d48..6eaaff92 100644 --- a/EhPanda/View/Home/Watched/WatchedReducer.swift +++ b/EhPanda/View/Home/Watched/WatchedReducer.swift @@ -136,7 +136,10 @@ struct WatchedReducer: Reducer { state.footerLoadingState = .loading let filter = databaseClient.fetchFilterSynchronously(range: .watched) return .run { [keyword = state.keyword] send in - let response = await MoreWatchedGalleriesRequest(filter: filter, lastID: lastID, keyword: keyword).response() + let response = await MoreWatchedGalleriesRequest( + filter: filter, lastID: lastID, keyword: keyword + ) + .response() await send(Action.fetchMoreGalleriesDone(response)) } .cancellable(id: CancelID.fetchMoreGalleries) diff --git a/EhPanda/View/Reading/ReadingReducer.swift b/EhPanda/View/Reading/ReadingReducer.swift index 7dbe483f..4ab37d99 100644 --- a/EhPanda/View/Reading/ReadingReducer.swift +++ b/EhPanda/View/Reading/ReadingReducer.swift @@ -541,7 +541,8 @@ struct ReadingReducer: Reducer { galleryURL: galleryURL, thumbnailURL: thumbnailURL, storedImageURL: imageURL - ).response() + ) + .response() await send(Action.refetchNormalImageURLsDone(index, response)) } .cancellable(id: CancelID.refetchNormalImageURLs) @@ -617,7 +618,8 @@ struct ReadingReducer: Reducer { mpvKey: mpvKey, mpvImageKey: mpvImageKey, skipServerIdentifier: skipServerIdentifier - ).response() + ) + .response() await send(Action.fetchMPVImageURLDone(index, response)) } .cancellable(id: CancelID.fetchMPVImageURL) diff --git a/EhPanda/View/Search/SearchReducer.swift b/EhPanda/View/Search/SearchReducer.swift index b35d981c..67099fc0 100644 --- a/EhPanda/View/Search/SearchReducer.swift +++ b/EhPanda/View/Search/SearchReducer.swift @@ -140,7 +140,10 @@ struct SearchReducer: Reducer { state.footerLoadingState = .loading let filter = databaseClient.fetchFilterSynchronously(range: .search) return .run { [lastKeyword = state.lastKeyword] send in - let response = await MoreSearchGalleriesRequest(keyword: lastKeyword, filter: filter, lastID: lastID).response() + let response = await MoreSearchGalleriesRequest( + keyword: lastKeyword, filter: filter, lastID: lastID + ) + .response() await send(Action.fetchMoreGalleriesDone(response)) } .cancellable(id: CancelID.fetchMoreGalleries)