Skip to content

Commit

Permalink
Refactor EhSetting feature
Browse files Browse the repository at this point in the history
  • Loading branch information
chihchy committed Nov 4, 2022
1 parent 3294d75 commit 49bd60e
Show file tree
Hide file tree
Showing 11 changed files with 65 additions and 111 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:
types: [closed]
env:
DEVELOPER_DIR: /Applications/Xcode_14.1.app
APP_VERSION: '2.4.4'
APP_VERSION: '2.4.5'
SCHEME_NAME: 'EhPanda'
ALTSTORE_JSON_PATH: './AltStore.json'
BUILDS_PATH: '/tmp/action-builds'
Expand Down
106 changes: 56 additions & 50 deletions EhPanda/App/Tools/Parser.swift

Large diffs are not rendered by default.

4 changes: 0 additions & 4 deletions EhPanda/App/de.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -530,10 +530,6 @@
"eh.setting.view.section.title.galleryPageNumbering" = "Gallery Page Numbering";
"eh.setting.view.title.showGalleryPageNumbers" = "Show gallery page numbers";

"eh.setting.view.section.title.hathLocalNetworkHost" = "Hath Local Network Host";
"eh.setting.view.title.ipAddressPort" = "IP address:Port";
"eh.setting.view.description.ipAddressPort" = "This setting can be used if you have a H@H client running on your local network with the same public IP you browse the site with. Some routers are buggy and cannot route requests back to its own IP; this allows you to work around this problem.\nIf you are running the client on the same device you browse from, use the loopback address (127.0.0.1:port). If the client is running on another device on your network, use its local network IP. Some browser configurations prevent external web sites from accessing URLs with local network IPs, the site must then be whitelisted for this to work.";

"eh.setting.view.section.title.originalImages" = "Original Images";
"eh.setting.view.title.useOriginalImages" = "Use original images";

Expand Down
4 changes: 0 additions & 4 deletions EhPanda/App/en.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -530,10 +530,6 @@
"eh.setting.view.section.title.galleryPageNumbering" = "Gallery Page Numbering";
"eh.setting.view.title.showGalleryPageNumbers" = "Show gallery page numbers";

"eh.setting.view.section.title.hathLocalNetworkHost" = "Hath Local Network Host";
"eh.setting.view.title.ipAddressPort" = "IP address:Port";
"eh.setting.view.description.ipAddressPort" = "This setting can be used if you have a H@H client running on your local network with the same public IP you browse the site with. Some routers are buggy and cannot route requests back to its own IP; this allows you to work around this problem.\nIf you are running the client on the same device you browse from, use the loopback address (127.0.0.1:port). If the client is running on another device on your network, use its local network IP. Some browser configurations prevent external web sites from accessing URLs with local network IPs, the site must then be whitelisted for this to work.";

"eh.setting.view.section.title.originalImages" = "Original Images";
"eh.setting.view.title.useOriginalImages" = "Use original images";

Expand Down
4 changes: 0 additions & 4 deletions EhPanda/App/ja.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -530,10 +530,6 @@
"eh.setting.view.section.title.galleryPageNumbering" = "ギャラリーページ数";
"eh.setting.view.title.showGalleryPageNumbers" = "ギャラリーページ数を表示";

"eh.setting.view.section.title.hathLocalNetworkHost" = "Hath ローカルネットワークホスト";
"eh.setting.view.title.ipAddressPort" = "IP アドレス:ポート";
"eh.setting.view.description.ipAddressPort" = "ローカルネットワークで今と同じパブリック IP を使う H@H クライアントがお持ちの場合、この設定が役立ちます。ルーターがバグが多くてリクエストを自分の IP にルートすることができないこともあります、それをこの設定で回避できます。\nH@H クライアントが今と同じデバイスで運行している場合はループバックアドレス(127.0.0.1:ポート)を使ってください。別のデバイスの場合はそのローカル IP を使ってください。かなりのブラウザの構成では外部サイトがローカル IP にアクセスすることをブロックしています、この設定を有効にするには本サイトをホワイトリストに入れてください。";

"eh.setting.view.section.title.originalImages" = "オリジナル画像";
"eh.setting.view.title.useOriginalImages" = "オリジナル画像を使う";

Expand Down
4 changes: 0 additions & 4 deletions EhPanda/App/ko.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -530,10 +530,6 @@
"eh.setting.view.section.title.galleryPageNumbering" = "갤러리 페이지 번호 매기기";
"eh.setting.view.title.showGalleryPageNumbers" = "갤러리 페이지 번호 보이기";

"eh.setting.view.section.title.hathLocalNetworkHost" = "Hath 로컬 네트워크 호스트";
"eh.setting.view.title.ipAddressPort" = "IP주소:포트";
"eh.setting.view.description.ipAddressPort" = "이 설정은 사이트를 검색하는 것과 동일한 공용 IP로 로컬 네트워크에서 H@H 클라이언트를 실행하는 경우 사용할 수 있습니다. 일부 라우터는 버그가 있어 요청을 자신의 IP로 다시 라우팅할 수 없기에, 아래를 따라서 이 문제를 해결할 수 있습니다.\n찾아보는 동일한 장치에서 클라이언트를 실행하는 경우 루프백 주소(127.0.0.1:port)를 사용할 수 있습니다. 클라이언트가 네트워크의 다른 장치에서 실행 중인 경우 로컬 네트워크 IP를 사용할 수 있습니다. 일부 브라우저 구성에서는 외부 웹 사이트가 로컬 네트워크 IP가 있는 URL에 액세스할 수 없도록 합니다. 그런 다음 사이트가 작동하려면 사이트를 화이트리스트에 추가해야 합니다.";

"eh.setting.view.section.title.originalImages" = "원본 이미지";
"eh.setting.view.title.useOriginalImages" = "원본 뷰어 적용";

Expand Down
4 changes: 0 additions & 4 deletions EhPanda/App/zh-Hans.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -530,10 +530,6 @@
"eh.setting.view.section.title.galleryPageNumbering" = "画廊页面页码";
"eh.setting.view.title.showGalleryPageNumbers" = "显示画廊页码";

"eh.setting.view.section.title.hathLocalNetworkHost" = "Hath 本地网络服务器";
"eh.setting.view.title.ipAddressPort" = "IP 地址:端口";
"eh.setting.view.description.ipAddressPort" = "如果你本地安装了 H@H 客户端,本地 IP 与浏览网站的公共 IP 相同,一些路由器不支持回流导致无法访问到自己,你可以设置这里来解决。\n如果在同一台设备上访问网站和运行客户端,请使用本地回环地址 (127.0.0.1:端口号)。如果客户端在网络上的其它设备运行,请使用那台机器的内网 IP。某些浏览器的配置可能阻止外部网站访问本地网络,你必须将网站列入白名单才能工作。";

"eh.setting.view.section.title.originalImages" = "原始图像";
"eh.setting.view.title.useOriginalImages" = "显示原图";

Expand Down
4 changes: 0 additions & 4 deletions EhPanda/App/zh-Hant.lproj/Localizable.strings
Original file line number Diff line number Diff line change
Expand Up @@ -530,10 +530,6 @@
"eh.setting.view.section.title.galleryPageNumbering" = "Gallery Page Numbering";
"eh.setting.view.title.showGalleryPageNumbers" = "Show gallery page numbers";

"eh.setting.view.section.title.hathLocalNetworkHost" = "Hath Local Network Host";
"eh.setting.view.title.ipAddressPort" = "IP address:Port";
"eh.setting.view.description.ipAddressPort" = "This setting can be used if you have a H@H client running on your local network with the same public IP you browse the site with. Some routers are buggy and cannot route requests back to its own IP; this allows you to work around this problem.\nIf you are running the client on the same device you browse from, use the loopback address (127.0.0.1:port). If the client is running on another device on your network, use its local network IP. Some browser configurations prevent external web sites from accessing URLs with local network IPs, the site must then be whitelisted for this to work.";

"eh.setting.view.section.title.originalImages" = "Original Images";
"eh.setting.view.title.useOriginalImages" = "Use original images";

Expand Down
14 changes: 7 additions & 7 deletions EhPanda/Models/Support/EhSetting.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
// MARK: EhSetting
struct EhSetting: Equatable {
// swiftlint:disable line_length
static let empty: Self = .init(ehProfiles: [.empty], capableLoadThroughHathSetting: .anyClient, capableImageResolution: .auto, capableSearchResultCount: .fifty, capableThumbnailConfigSize: .normal, capableThumbnailConfigRowCount: .forty, loadThroughHathSetting: .anyClient, browsingCountry: .autoDetect, literalBrowsingCountry: "", imageResolution: .auto, imageSizeWidth: 0, imageSizeHeight: 0, galleryName: .default, archiverBehavior: .autoSelectOriginalAutoStart, displayMode: .compact, disabledCategories: Array(repeating: false, count: 10), favoriteCategories: Array(repeating: "", count: 10), favoritesSortOrder: .favoritedTime, ratingsColor: "", excludedNamespaces: Array(repeating: false, count: 11), tagFilteringThreshold: 0, tagWatchingThreshold: 0, excludedLanguages: Array(repeating: false, count: 50), excludedUploaders: "", searchResultCount: .fifty, thumbnailLoadTiming: .onPageLoad, thumbnailConfigSize: .normal, thumbnailConfigRows: .ten, thumbnailScaleFactor: 0, viewportVirtualWidth: 0, commentsSortOrder: .recent, commentVotesShowTiming: .always, tagsSortOrder: .alphabetical, galleryShowPageNumbers: true /*, hathLocalNetworkHost: "" */)
static let empty: Self = .init(ehProfiles: [.empty], isCapableOfCreatingNewProfile: true, capableLoadThroughHathSetting: .anyClient, capableImageResolution: .auto, capableSearchResultCount: .fifty, capableThumbnailConfigSize: .normal, capableThumbnailConfigRowCount: .forty, loadThroughHathSetting: .anyClient, browsingCountry: .autoDetect, literalBrowsingCountry: "", imageResolution: .auto, imageSizeWidth: 0, imageSizeHeight: 0, galleryName: .default, archiverBehavior: .autoSelectOriginalAutoStart, displayMode: .compact, disabledCategories: Array(repeating: false, count: 10), favoriteCategories: Array(repeating: "", count: 10), favoritesSortOrder: .favoritedTime, ratingsColor: "", excludedNamespaces: Array(repeating: false, count: 11), tagFilteringThreshold: 0, tagWatchingThreshold: 0, excludedLanguages: Array(repeating: false, count: 50), excludedUploaders: "", searchResultCount: .fifty, thumbnailLoadTiming: .onPageLoad, thumbnailConfigSize: .normal, thumbnailConfigRows: .ten, thumbnailScaleFactor: 0, viewportVirtualWidth: 0, commentsSortOrder: .recent, commentVotesShowTiming: .always, tagsSortOrder: .alphabetical, galleryShowPageNumbers: true)
// swiftlint:enable line_length

static let categoryNames = Category.allFiltersCases.map(\.rawValue).map { value in
Expand All @@ -31,11 +31,12 @@ struct EhSetting: Equatable {
["EhPanda", "EhPanda (Default)"].contains(name ?? "")
}

var capableLoadThroughHathSetting: LoadThroughHathSetting
var capableImageResolution: ImageResolution
var capableSearchResultCount: SearchResultCount
var capableThumbnailConfigSize: ThumbnailSize
var capableThumbnailConfigRowCount: ThumbnailRowCount
let isCapableOfCreatingNewProfile: Bool
let capableLoadThroughHathSetting: LoadThroughHathSetting
let capableImageResolution: ImageResolution
let capableSearchResultCount: SearchResultCount
let capableThumbnailConfigSize: ThumbnailSize
let capableThumbnailConfigRowCount: ThumbnailRowCount

var capableLoadThroughHathSettings: [LoadThroughHathSetting] {
LoadThroughHathSetting.allCases.filter { setting in
Expand Down Expand Up @@ -94,7 +95,6 @@ struct EhSetting: Equatable {
var commentVotesShowTiming: CommentVotesShowTiming
var tagsSortOrder: TagsSortOrder
var galleryShowPageNumbers: Bool
// var hathLocalNetworkHost: String
var useOriginalImages: Bool?
var useMultiplePageViewer: Bool?
var multiplePageViewerStyle: MultiplePageViewerStyle?
Expand Down
1 change: 0 additions & 1 deletion EhPanda/Network/Request.swift
Original file line number Diff line number Diff line change
Expand Up @@ -701,7 +701,6 @@ struct SubmitEhSettingChangesRequest: Request {
"sc": String(ehSetting.commentVotesShowTiming.rawValue),
"tb": String(ehSetting.tagsSortOrder.rawValue),
"pn": ehSetting.galleryShowPageNumbers ? "1" : "0",
/* "hh": ehSetting.hathLocalNetworkHost, */
"apply": "Apply"
]

Expand Down
29 changes: 1 addition & 28 deletions EhPanda/View/Setting/Support/EhSettingView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@ struct EhSettingView: View {
GalleryPageNumberingSection(ehSetting: ehSetting)
}
Group {
// HathLocalNetworkHostSection(ehSetting: ehSetting)
OriginalImagesSection(ehSetting: ehSetting)
MultiplePageViewerSection(ehSetting: ehSetting)
}
Expand Down Expand Up @@ -199,7 +198,7 @@ private struct EhProfileSection: View {
performEhProfileAction(.rename, editingProfileName, ehProfile.value)
}
.disabled(isFocused)
if ehSetting.ehProfiles.count < 10 {
if ehSetting.isCapableOfCreatingNewProfile {
Button(R.string.localizable.ehSettingViewButtonCreateNew()) {
performEhProfileAction(.create, editingProfileName, ehProfile.value)
}
Expand Down Expand Up @@ -894,32 +893,6 @@ private struct GalleryPageNumberingSection: View {
}
}

/*
// MARK: HathLocalNetworkHostSection
private struct HathLocalNetworkHostSection: View {
@Binding private var ehSetting: EhSetting
@FocusState var isFocused

init(ehSetting: Binding<EhSetting>) {
_ehSetting = ehSetting
}

var body: some View {
Section(
header: Text(R.string.localizable.ehSettingViewSectionTitleHathLocalNetworkHost()).newlineBold()
+ Text(R.string.localizable.ehSettingViewDescriptionIpAddressPort())
) {
HStack {
Text(R.string.localizable.ehSettingViewTitleIpAddressPort())
Spacer()
SettingTextField(text: $ehSetting.hathLocalNetworkHost, width: 150).focused($isFocused)
}
}
.textCase(nil)
}
}
*/

// MARK: OriginalImagesSection
private struct OriginalImagesSection: View {
@Binding private var ehSetting: EhSetting
Expand Down

0 comments on commit 49bd60e

Please sign in to comment.