Skip to content

Commit

Permalink
Resolve warnings & enforce code style
Browse files Browse the repository at this point in the history
  • Loading branch information
chihchy committed May 30, 2024
1 parent 0f475cc commit fd7805a
Show file tree
Hide file tree
Showing 20 changed files with 107 additions and 76 deletions.
1 change: 1 addition & 0 deletions .swiftlint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,4 @@ identifier_name:

excluded:
- EhPandaTests
- EhPanda/App/Generated
9 changes: 6 additions & 3 deletions EhPanda/DataFlow/AppRouteReducer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,11 @@ 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()
await send(Action.fetchGalleryDone(url, response))
let response = await GalleryReverseRequest(
url: url, isGalleryImageURL: isGalleryImageURL
)
.response()
await send(.fetchGalleryDone(url, response))
}

case .fetchGalleryDone(let url, let result):
Expand All @@ -164,7 +167,7 @@ struct AppRouteReducer: Reducer {
case .failure:
return .run { send in
try await Task.sleep(for: .milliseconds(500))
await send(Action.setHUDConfig(.error))
await send(.setHUDConfig(.error))
}
}

Expand Down
7 changes: 0 additions & 7 deletions EhPanda/Models/Tags/TagDetail.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
9 changes: 5 additions & 4 deletions EhPanda/View/Detail/Archives/ArchivesReducer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ struct ArchivesReducer: Reducer {
state.loadingState = .loading
return .run { send in
let response = await GalleryArchiveRequest(archiveURL: archiveURL).response()
await send(Action.fetchArchiveDone(gid, galleryURL, response))
await send(.fetchArchiveDone(gid, galleryURL, response))
}
.cancellable(id: CancelID.fetchArchive)

Expand Down Expand Up @@ -103,7 +103,7 @@ struct ArchivesReducer: Reducer {
guard let galleryURL = galleryURL.replaceHost(to: Defaults.URL.ehentai.host) else { return .none }
return .run { send in
let response = await GalleryArchiveFundsRequest(gid: gid, galleryURL: galleryURL).response()
await send(Action.fetchArchiveFundsDone(response))
await send(.fetchArchiveFundsDone(response))
}
.cancellable(id: CancelID.fetchArchiveFunds)

Expand All @@ -122,8 +122,9 @@ struct ArchivesReducer: Reducer {
let response = await SendDownloadCommandRequest(
archiveURL: archiveURL,
resolution: selectedArchive.resolution.parameter
).response()
await send(Action.fetchDownloadResponseDone(response))
)
.response()
await send(.fetchDownloadResponseDone(response))
}
.cancellable(id: CancelID.fetchDownloadResponse)

Expand Down
24 changes: 16 additions & 8 deletions EhPanda/View/Detail/Comments/CommentsReducer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -193,14 +193,18 @@ struct CommentsReducer: Reducer {
commentID: commentID,
content: commentContent,
galleryURL: galleryURL
).response()
await send(Action.performCommentActionDone(response))
)
.response()
await send(.performCommentActionDone(response))
}
.cancellable(id: CancelID.postComment)
} else {
return .run { [commentContent = state.commentContent] send in
let response = await CommentGalleryRequest(content: commentContent, galleryURL: galleryURL).response()
await send(Action.performCommentActionDone(response))
let response = await CommentGalleryRequest(
content: commentContent, galleryURL: galleryURL
)
.response()
await send(.performCommentActionDone(response))
}
.cancellable(id: CancelID.postComment)
}
Expand All @@ -217,8 +221,9 @@ struct CommentsReducer: Reducer {
token: token,
commentID: commentID,
commentVote: vote
).response()
await send(Action.performCommentActionDone(response))
)
.response()
await send(.performCommentActionDone(response))
}
.cancellable(id: CancelID.voteComment)

Expand All @@ -228,8 +233,11 @@ 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()
await send(Action.fetchGalleryDone(url, response))
let response = await GalleryReverseRequest(
url: url, isGalleryImageURL: isGalleryImageURL
)
.response()
await send(.fetchGalleryDone(url, response))
}
.cancellable(id: CancelID.fetchGallery)

Expand Down
26 changes: 16 additions & 10 deletions EhPanda/View/Detail/DetailReducer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ struct DetailReducer: Reducer {
state.loadingState = .loading
return .run { [galleryID = state.gallery.id] send in
let response = await GalleryDetailRequest(gid: galleryID, galleryURL: galleryURL).response()
await send(Action.fetchGalleryDetailDone(response))
await send(.fetchGalleryDetailDone(response))
}
.cancellable(id: CancelID.fetchGalleryDetail)

Expand Down Expand Up @@ -325,8 +325,9 @@ struct DetailReducer: Reducer {
gid: gid,
token: state.gallery.token,
rating: state.userRating
).response()
await send(Action.anyGalleryOpsDone(response))
)
.response()
await send(.anyGalleryOpsDone(response))
}.cancellable(id: CancelID.rateGallery)

case .favorGallery(let favIndex):
Expand All @@ -335,23 +336,27 @@ struct DetailReducer: Reducer {
gid: state.gallery.id,
token: state.gallery.token,
favIndex: favIndex
).response()
await send(Action.anyGalleryOpsDone(response))
)
.response()
await send(.anyGalleryOpsDone(response))
}
.cancellable(id: CancelID.favorGallery)

case .unfavorGallery:
return .run { [galleryID = state.gallery.id] send in
let response = await UnfavorGalleryRequest(gid: galleryID).response()
await send(Action.anyGalleryOpsDone(response))
await send(.anyGalleryOpsDone(response))
}
.cancellable(id: CancelID.unfavorGallery)

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()
await send(Action.anyGalleryOpsDone(response))
let response = await CommentGalleryRequest(
content: commentContent, galleryURL: galleryURL
)
.response()
await send(.anyGalleryOpsDone(response))
}
.cancellable(id: CancelID.postComment)

Expand All @@ -366,8 +371,9 @@ struct DetailReducer: Reducer {
token: state.gallery.token,
tag: tag,
vote: vote
).response()
await send(Action.anyGalleryOpsDone(response))
)
.response()
await send(.anyGalleryOpsDone(response))
}
.cancellable(id: CancelID.voteTag)

Expand Down
9 changes: 6 additions & 3 deletions EhPanda/View/Detail/DetailSearch/DetailSearchReducer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ struct DetailSearchReducer: Reducer {
let filter = databaseClient.fetchFilterSynchronously(range: .search)
return .run { [lastKeyword = state.lastKeyword] send in
let response = await SearchGalleriesRequest(keyword: lastKeyword, filter: filter).response()
await send(Action.fetchGalleriesDone(response))
await send(.fetchGalleriesDone(response))
}
.cancellable(id: CancelID.fetchGalleries)

Expand Down Expand Up @@ -140,8 +140,11 @@ 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()
await send(Action.fetchMoreGalleriesDone(response))
let response = await MoreSearchGalleriesRequest(
keyword: lastKeyword, filter: filter, lastID: lastID
)
.response()
await send(.fetchMoreGalleriesDone(response))
}
.cancellable(id: CancelID.fetchMoreGalleries)

Expand Down
2 changes: 1 addition & 1 deletion EhPanda/View/Detail/Previews/PreviewsReducer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ struct PreviewsReducer: Reducer {
let pageNum = state.previewConfig.pageNumber(index: index)
return .run { send in
let response = await GalleryPreviewURLsRequest(galleryURL: galleryURL, pageNum: pageNum).response()
await send(Action.fetchPreviewURLsDone(response))
await send(.fetchPreviewURLsDone(response))
}
.cancellable(id: CancelID.fetchPreviewURLs)

Expand Down
4 changes: 2 additions & 2 deletions EhPanda/View/Detail/Torrents/TorrentsReducer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ struct TorrentsReducer: Reducer {
case .fetchTorrent(let hash, let torrentURL):
return .run { send in
let response = await DataRequest(url: torrentURL).response()
await send(Action.fetchTorrentDone(hash, response))
await send(.fetchTorrentDone(hash, response))
}
.cancellable(id: CancelID.fetchTorrent)

Expand All @@ -94,7 +94,7 @@ struct TorrentsReducer: Reducer {
state.loadingState = .loading
return .run { send in
let response = await GalleryTorrentsRequest(gid: gid, token: token).response()
await send(Action.fetchGalleryTorrentsDone(response))
await send(.fetchGalleryTorrentsDone(response))
}
.cancellable(id: CancelID.fetchGalleryTorrents)

Expand Down
12 changes: 7 additions & 5 deletions EhPanda/View/Favorites/FavoritesReducer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ struct FavoritesReducer: Reducer {
case .setFavoritesIndex(let index):
state.index = index
guard state.galleries?.isEmpty != false else { return .none }
return .send(Action.fetchGalleries())
return .send(.fetchGalleries())

case .clearSubStates:
state.detailState = .init()
Expand All @@ -116,8 +116,9 @@ struct FavoritesReducer: Reducer {
return .run { [state] send in
let response = await FavoritesGalleriesRequest(
favIndex: state.index, keyword: state.keyword, sortOrder: sortOrder
).response()
await send(Action.fetchGalleriesDone(state.index, response))
)
.response()
await send(.fetchGalleriesDone(state.index, response))
}

case .fetchGalleriesDone(let targetFavIndex, let result):
Expand Down Expand Up @@ -154,8 +155,9 @@ struct FavoritesReducer: Reducer {
lastID: lastID,
lastTimestamp: lastItemTimestamp,
keyword: state.keyword
).response()
await send(Action.fetchMoreGalleriesDone(state.index, response))
)
.response()
await send(.fetchMoreGalleriesDone(state.index, response))
}

case .fetchMoreGalleriesDone(let targetFavIndex, let result):
Expand Down
4 changes: 2 additions & 2 deletions EhPanda/View/Home/Frontpage/FrontpageReducer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ struct FrontpageReducer: Reducer {
let filter = databaseClient.fetchFilterSynchronously(range: .global)
return .run { send in
let response = await FrontpageGalleriesRequest(filter: filter).response()
await send(Action.fetchGalleriesDone(response))
await send(.fetchGalleriesDone(response))
}
.cancellable(id: CancelID.fetchGalleries)

Expand Down Expand Up @@ -127,7 +127,7 @@ struct FrontpageReducer: Reducer {
let filter = databaseClient.fetchFilterSynchronously(range: .global)
return .run { send in
let response = await MoreFrontpageGalleriesRequest(filter: filter, lastID: lastID).response()
await send(Action.fetchMoreGalleriesDone(response))
await send(.fetchMoreGalleriesDone(response))
}
.cancellable(id: CancelID.fetchMoreGalleries)

Expand Down
6 changes: 3 additions & 3 deletions EhPanda/View/Home/HomeReducer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ struct HomeReducer: Reducer {
let filter = databaseClient.fetchFilterSynchronously(range: .global)
return .run { send in
let response = await PopularGalleriesRequest(filter: filter).response()
await send(Action.fetchPopularGalleriesDone(response))
await send(.fetchPopularGalleriesDone(response))
}

case .fetchPopularGalleriesDone(let result):
Expand All @@ -183,7 +183,7 @@ struct HomeReducer: Reducer {
let filter = databaseClient.fetchFilterSynchronously(range: .global)
return .run { send in
let response = await FrontpageGalleriesRequest(filter: filter).response()
await send(Action.fetchFrontpageGalleriesDone(response))
await send(.fetchFrontpageGalleriesDone(response))
}

case .fetchFrontpageGalleriesDone(let result):
Expand All @@ -208,7 +208,7 @@ struct HomeReducer: Reducer {
state.toplistsLoadingState[index] = .loading
return .run { send in
let response = await ToplistsGalleriesRequest(catIndex: index, pageNum: pageNum).response()
await send(Action.fetchToplistsGalleriesDone(index, response))
await send(.fetchToplistsGalleriesDone(index, response))
}

case .fetchToplistsGalleriesDone(let index, let result):
Expand Down
2 changes: 1 addition & 1 deletion EhPanda/View/Home/Popular/PopularReducer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ struct PopularReducer: Reducer {
let filter = databaseClient.fetchFilterSynchronously(range: .global)
return .run { send in
let response = await PopularGalleriesRequest(filter: filter).response()
await send(Action.fetchGalleriesDone(response))
await send(.fetchGalleriesDone(response))
}
.cancellable(id: CancelID.fetchGalleries)

Expand Down
16 changes: 11 additions & 5 deletions EhPanda/View/Home/Toplists/ToplistsReducer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ struct ToplistsReducer: Reducer {
case .setToplistsType(let type):
state.type = type
guard state.galleries?.isEmpty != false else { return .none }
return .send(Action.fetchGalleries())
return .send(.fetchGalleries())

case .clearSubStates:
state.detailState = .init()
Expand Down Expand Up @@ -147,8 +147,11 @@ 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()
await send(Action.fetchGalleriesDone(type, response))
let response = await ToplistsGalleriesRequest(
catIndex: type.categoryIndex, pageNum: pageNum
)
.response()
await send(.fetchGalleriesDone(type, response))
}
.cancellable(id: CancelID.fetchGalleries)

Expand Down Expand Up @@ -179,8 +182,11 @@ 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()
await send(Action.fetchMoreGalleriesDone(type, response))
let response = await MoreToplistsGalleriesRequest(
catIndex: type.categoryIndex, pageNum: pageNum
)
.response()
await send(.fetchMoreGalleriesDone(type, response))
}
.cancellable(id: CancelID.fetchMoreGalleries)

Expand Down
9 changes: 6 additions & 3 deletions EhPanda/View/Home/Watched/WatchedReducer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ struct WatchedReducer: Reducer {
let filter = databaseClient.fetchFilterSynchronously(range: .watched)
return .run { [keyword = state.keyword] send in
let response = await WatchedGalleriesRequest(filter: filter, keyword: keyword).response()
await send(Action.fetchGalleriesDone(response))
await send(.fetchGalleriesDone(response))
}
.cancellable(id: CancelID.fetchGalleries)

Expand Down Expand Up @@ -136,8 +136,11 @@ 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()
await send(Action.fetchMoreGalleriesDone(response))
let response = await MoreWatchedGalleriesRequest(
filter: filter, lastID: lastID, keyword: keyword
)
.response()
await send(.fetchMoreGalleriesDone(response))
}
.cancellable(id: CancelID.fetchMoreGalleries)

Expand Down
Loading

0 comments on commit fd7805a

Please sign in to comment.