summaryrefslogtreecommitdiff
path: root/Sora/Views/Settings/Section/SettingsSectionProviderView.swift
diff options
context:
space:
mode:
authorFuwn <[email protected]>2026-02-23 08:20:28 -0800
committerFuwn <[email protected]>2026-02-23 08:21:50 -0800
commit13762193cf21624e6bab5e8f3c12ace320e39661 (patch)
treeb99599caa5062c2bf2f363168262e41ebc26b788 /Sora/Views/Settings/Section/SettingsSectionProviderView.swift
parentchore: deduplicate project build settings in xcodegen spec (diff)
downloadsora-testing-13762193cf21624e6bab5e8f3c12ace320e39661.tar.xz
sora-testing-13762193cf21624e6bab5e8f3c12ace320e39661.zip
fix: use Danbooru login/api_key query auth
Diffstat (limited to 'Sora/Views/Settings/Section/SettingsSectionProviderView.swift')
-rw-r--r--Sora/Views/Settings/Section/SettingsSectionProviderView.swift28
1 files changed, 23 insertions, 5 deletions
diff --git a/Sora/Views/Settings/Section/SettingsSectionProviderView.swift b/Sora/Views/Settings/Section/SettingsSectionProviderView.swift
index 02c5b02..172ddc6 100644
--- a/Sora/Views/Settings/Section/SettingsSectionProviderView.swift
+++ b/Sora/Views/Settings/Section/SettingsSectionProviderView.swift
@@ -33,12 +33,24 @@ struct SettingsSectionProviderView: View {
.autocorrectionDisabled(true)
TextField(
- "User ID",
+ isDanbooruProvider ? "Login" : "User ID",
text: Binding(
get: {
- String(settings.providerUserIDs[settings.preferredBooru] ?? 0)
+ if isDanbooruProvider {
+ return settings.providerLogins[settings.preferredBooru] ?? ""
+ }
+
+ let userID = settings.providerUserIDs[settings.preferredBooru] ?? 0
+
+ return userID == 0 ? "" : String(userID)
},
set: { newValue in
+ if isDanbooruProvider {
+ updateCredentials(login: newValue.trimmingCharacters(in: .whitespacesAndNewlines))
+
+ return
+ }
+
let userID = Int(newValue) ?? 0
updateCredentials(userID: userID)
@@ -47,7 +59,7 @@ struct SettingsSectionProviderView: View {
)
.autocorrectionDisabled(true)
#if os(iOS)
- .keyboardType(.numberPad)
+ .keyboardType(isDanbooruProvider ? .default : .numberPad)
#endif
}
@@ -197,7 +209,11 @@ struct SettingsSectionProviderView: View {
return true
}
- private func updateCredentials(apiKey: String? = nil, userID: Int? = nil) {
+ private var isDanbooruProvider: Bool {
+ BooruProviderFlavor(provider: settings.preferredBooru) == .danbooru
+ }
+
+ private func updateCredentials(apiKey: String? = nil, userID: Int? = nil, login: String? = nil) {
var allCredentials = settings.providerCredentials
if let index = allCredentials.firstIndex(where: { $0.provider == settings.preferredBooru }) {
@@ -207,6 +223,7 @@ struct SettingsSectionProviderView: View {
provider: credentials.provider,
apiKey: apiKey ?? credentials.apiKey,
userID: userID ?? credentials.userID,
+ login: login ?? credentials.login,
id: credentials.id
)
} else {
@@ -214,7 +231,8 @@ struct SettingsSectionProviderView: View {
BooruProviderCredentials(
provider: settings.preferredBooru,
apiKey: apiKey ?? "",
- userID: userID ?? 0
+ userID: userID ?? 0,
+ login: login ?? ""
)
)
}