Add an optional frontend URL for Piped instances used by browser actions

This commit is contained in:
Arkadiusz Fal
2026-09-18 23:36:11 +02:00
parent 045e0ba574
commit 172d712f25
4 changed files with 70 additions and 3 deletions

View File

@@ -175,7 +175,7 @@ struct InstanceBrowseView: View {
}
Button {
openURL(instance.url)
openURL(instance.browseURL)
} label: {
Label(String(localized: "instance.browse.openInBrowser"), systemImage: "safari")
}
@@ -257,10 +257,10 @@ struct InstanceBrowseView: View {
private func copyInstanceURL() {
#if os(iOS)
UIPasteboard.general.string = instance.url.absoluteString
UIPasteboard.general.string = instance.browseURL.absoluteString
#elseif os(macOS)
NSPasteboard.general.clearContents()
NSPasteboard.general.setString(instance.url.absoluteString, forType: .string)
NSPasteboard.general.setString(instance.browseURL.absoluteString, forType: .string)
#endif
}

View File

@@ -36,6 +36,10 @@ private struct EditRemoteServerContent: View {
@State private var allowInvalidCertificates: Bool
@State private var proxiesVideos: Bool
// Piped serves its API and web frontend from separate hosts; browser-facing
// actions (open in browser, copy link) use this URL when set.
@State private var frontendURLString: String
// HTTP Basic Auth credentials (for any instance type behind a reverse proxy;
// required for Yattee Server, optional for Invidious/Piped/PeerTube).
@State private var basicAuthUsername: String = ""
@@ -66,6 +70,7 @@ private struct EditRemoteServerContent: View {
_isEnabled = State(initialValue: instance.isEnabled)
_allowInvalidCertificates = State(initialValue: instance.allowInvalidCertificates)
_proxiesVideos = State(initialValue: instance.proxiesVideos)
_frontendURLString = State(initialValue: instance.frontendURL?.absoluteString ?? "")
}
var body: some View {
@@ -121,6 +126,27 @@ private struct EditRemoteServerContent: View {
#endif
}
if instance.type == .piped {
Section {
#if os(tvOS)
TVSettingsTextField(title: String(localized: "sources.field.frontendURL"), text: $frontendURLString)
#elseif os(macOS)
LabeledContent(String(localized: "sources.field.frontendURL")) {
TextField("", text: $frontendURLString)
.autocorrectionDisabled()
}
#else
TextField(String(localized: "sources.field.frontendURL"), text: $frontendURLString)
.textContentType(.URL)
.keyboardType(.URL)
.textInputAutocapitalization(.never)
.autocorrectionDisabled()
#endif
} footer: {
Text(String(localized: "sources.footer.frontendURL"))
}
}
if instance.type == .yatteeServer {
// Server Info Section
Section {
@@ -465,6 +491,11 @@ private struct EditRemoteServerContent: View {
updated.allowInvalidCertificates = allowInvalidCertificates
updated.proxiesVideos = proxiesVideos
if instance.type == .piped {
let trimmed = frontendURLString.trimmingCharacters(in: .whitespacesAndNewlines)
updated.frontendURL = trimmed.isEmpty ? nil : Instance.normalizeSourceURL(trimmed)
}
// Save / clear HTTP Basic Auth credentials. Yattee Server never auto-clears
// (credentials are required and the user re-enters to overwrite). Piped never
// persists them — its session token reuses the same Authorization header.