Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resolve warnings & enforce code style & refactoring #377

Merged
merged 3 commits into from
May 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 4 additions & 6 deletions .github/workflows/dependencies.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,13 @@ name: Xcode Dependencies
on:
schedule:
- cron: '0 0 * * 1'
push:
branches:
- main
workflow_dispatch:
permissions:
contents: write
pull-requests: write
jobs:
dependencies:
runs-on: macos-13
if: ${{ contains(github.event.head_commit.message, '[update dependencies]') || github.event_name == 'schedule' }}
runs-on: macos-14
steps:
- uses: actions/checkout@v4
with:
Expand All @@ -22,9 +19,10 @@ jobs:
with:
forceResolution: true
failWhenOutdated: false
xcodePath: '/Applications/Xcode_15.4.app'
- name: Create Pull Request
if: steps.resolution.outputs.dependenciesChanged == 'true'
uses: peter-evans/create-pull-request@v5
uses: peter-evans/create-pull-request@v6
with:
branch: 'update-dependencies'
delete-branch: true
Expand Down
24 changes: 17 additions & 7 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ on:
- main
types: [closed]
env:
DEVELOPER_DIR: /Applications/Xcode_15.0.1.app
DEVELOPER_DIR: /Applications/Xcode_15.4.app
APP_VERSION: '2.7.4'
SCHEME_NAME: 'EhPanda'
ALTSTORE_JSON_PATH: './AltStore.json'
Expand All @@ -19,7 +19,7 @@ env:

jobs:
Deploy:
runs-on: macos-13
runs-on: macos-14
if: github.event.pull_request.merged == true && github.event.pull_request.user.login == 'chihchy'
steps:
- name: Checkout
Expand All @@ -28,21 +28,31 @@ jobs:
run: |
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
- name: Install dependencies
run: brew install swiftgen
- name: Show Xcode version
run: xcodebuild -version
- name: Run tests
run: xcodebuild clean test -scheme ${{ env.SCHEME_NAME }} -sdk iphonesimulator
run: xcodebuild clean test
-skipMacroValidation
-sdk iphonesimulator
-scheme ${{ env.SCHEME_NAME }}
-destination 'platform=iOS Simulator,name=iPhone 15 Pro'
- name: Bump version
id: bump-version
uses: yanamura/ios-bump-version@v1
with:
version: ${{ env.APP_VERSION }}
- name: Xcode archive
run: xcodebuild archive -destination 'generic/platform=iOS'
-scheme ${{ env.SCHEME_NAME }} -archivePath ${{ env.ARCHIVE_PATH }} CODE_SIGNING_REQUIRED=NO CODE_SIGNING_ALLOWED=NO CODE_SIGN_IDENTITY= CODE_SIGN_ENTITLEMENTS= GCC_OPTIMIZATION_LEVEL=s SWIFT_OPTIMIZATION_LEVEL=-O
run: xcodebuild archive
-skipMacroValidation
-scheme ${{ env.SCHEME_NAME }}
-destination 'generic/platform=iOS'
-archivePath ${{ env.ARCHIVE_PATH }}
CODE_SIGN_IDENTITY=
CODE_SIGN_ENTITLEMENTS=
CODE_SIGNING_ALLOWED=NO
CODE_SIGNING_REQUIRED=NO
GCC_OPTIMIZATION_LEVEL=s
SWIFT_OPTIMIZATION_LEVEL=-O
- name: Export .ipa file
run: |
mkdir -p ${{ env.PAYLOAD_PATH }}
Expand Down
12 changes: 6 additions & 6 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
name: Test
on: [push]
on: [push, workflow_dispatch]
env:
SCHEME_NAME: 'EhPanda'
DEVELOPER_DIR: /Applications/Xcode_15.0.1.app
DEVELOPER_DIR: /Applications/Xcode_15.4.app
jobs:
Test:
runs-on: macos-13
runs-on: macos-14
if: ${{ !contains(github.event.head_commit.message, '[skip test]') }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install dependencies
run: brew install swiftgen
- name: Show Xcode version
run: xcodebuild -version
- name: Run tests
run: xcodebuild clean test
-scheme ${{ env.SCHEME_NAME }} -sdk iphonesimulator
-skipMacroValidation
-sdk iphonesimulator
-scheme ${{ env.SCHEME_NAME }}
-destination 'platform=iOS Simulator,name=iPhone 15 Pro'
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
.DS_Store
EhPanda/App/Generated
EhPanda.xcodeproj/xcuserdata
EhPanda.xcodeproj/project.xcworkspace/xcuserdata
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
2,225 changes: 2,225 additions & 0 deletions EhPanda/App/Generated/Strings.swift

Large diffs are not rendered by default.

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
Loading