summaryrefslogtreecommitdiff
path: root/Sora/Views
diff options
context:
space:
mode:
authorFuwn <[email protected]>2026-03-22 13:20:36 +0000
committerFuwn <[email protected]>2026-03-22 13:20:36 +0000
commit2b62f719849cce5dd43fef1b679fff3a2243fcdf (patch)
treecf49424478aa71fcfb8a94b9af4a7b3b01f49908 /Sora/Views
parentperf: cache danbooru page token floor and reuse search-history payloads (diff)
downloadsora-testing-2b62f719849cce5dd43fef1b679fff3a2243fcdf.tar.xz
sora-testing-2b62f719849cce5dd43fef1b679fff3a2243fcdf.zip
feat: add configurable booru user agent settings
Diffstat (limited to 'Sora/Views')
-rw-r--r--Sora/Views/MainView.swift10
-rw-r--r--Sora/Views/Settings/Section/SettingsSectionProviderView.swift13
2 files changed, 21 insertions, 2 deletions
diff --git a/Sora/Views/MainView.swift b/Sora/Views/MainView.swift
index 770d424..603f7a1 100644
--- a/Sora/Views/MainView.swift
+++ b/Sora/Views/MainView.swift
@@ -18,8 +18,10 @@ struct MainView: View {
}
}
.onAppear(perform: initializeManager)
- .onChange(of: settings.providerCredentials) { initializeManager() }
- .onChange(of: settings.showHeldMoebooruPosts) { initializeManager() }
+ .onChange(of: settings.providerCredentials) { updateManager(settings.preferredBooru) }
+ .onChange(of: settings.showHeldMoebooruPosts) { updateManager(settings.preferredBooru) }
+ .onChange(of: settings.sendBooruUserAgent) { updateManager(settings.preferredBooru) }
+ .onChange(of: settings.customBooruUserAgent) { updateManager(settings.preferredBooru) }
#if os(macOS)
.onChange(of: selectedTab) { _, newValue in
if newValue == 0 {
@@ -121,6 +123,8 @@ struct MainView: View {
provider,
credentials: settings.providerCredentials
.first { $0.provider == settings.preferredBooru },
+ sendUserAgent: settings.sendBooruUserAgent,
+ customUserAgent: settings.customBooruUserAgent,
showHeldMoebooruPosts: settings.showHeldMoebooruPosts
)
manager.searchText = previousSearchText
@@ -139,6 +143,8 @@ struct MainView: View {
settings.preferredBooru,
credentials: settings.providerCredentials
.first { $0.provider == settings.preferredBooru },
+ sendUserAgent: settings.sendBooruUserAgent,
+ customUserAgent: settings.customBooruUserAgent,
showHeldMoebooruPosts: settings.showHeldMoebooruPosts
)
diff --git a/Sora/Views/Settings/Section/SettingsSectionProviderView.swift b/Sora/Views/Settings/Section/SettingsSectionProviderView.swift
index cbfae37..031840a 100644
--- a/Sora/Views/Settings/Section/SettingsSectionProviderView.swift
+++ b/Sora/Views/Settings/Section/SettingsSectionProviderView.swift
@@ -26,6 +26,19 @@ struct SettingsSectionProviderView: View {
Toggle("Show Held Posts", isOn: $settings.showHeldMoebooruPosts)
}
+ Section(header: Text("User-Agent")) {
+ Toggle("Send User-Agent", isOn: $settings.sendBooruUserAgent)
+
+ if settings.sendBooruUserAgent {
+ TextField("Custom User-Agent", text: $settings.customBooruUserAgent)
+ .autocorrectionDisabled(true)
+
+ Text("Leave this field empty to use Sora's default User-Agent.")
+ .font(.caption)
+ .foregroundStyle(.secondary)
+ }
+ }
+
Section(header: Text("API Credentials")) {
SecureField(
"API Key",