7e1c37db7f
The previous commit hardcoded https://preview.org-social.org/ as the preview service for the Share button on each post. Now both the toggle and the URL are user-configurable: - New UserDefaults keys, registered with sensible defaults in OrgSocialApp.init: previewServiceEnabled (true), previewServiceURL ("https://preview.org-social.org/"). - SettingsViewModel exposes both as @Observable properties, persists them in saveIfValid, and adds previewServiceValid -> canSave so the URL must be a valid HTTP(S) URL when the toggle is on (when off the field is irrelevant and validation passes). - SettingsView gets a new "Sharing" section between Relay and Migration, with a Toggle and a conditionally-shown Preview URL field. Field disappears entirely when the toggle is off. - PostRowView reads previewServiceEnabled at render time, hiding the ShareLink when off, and reads previewServiceURL when building the share URL (tolerates trailing slash both ways). Bundle behaviour: existing installs default to "on" + the public preview service, so nothing changes for current users until they opt out.
25 lines
676 B
Swift
25 lines
676 B
Swift
import SwiftUI
|
|
|
|
@main
|
|
struct OrgSocialApp: App {
|
|
|
|
init() {
|
|
// Production defaults: no account pre-populated. First-run users see WelcomeView
|
|
// and either sign up on host.org-social.org or paste an existing config in Settings.
|
|
UserDefaults.standard.register(defaults: [
|
|
"relayURL": "https://relay.org-social.org",
|
|
"maxPostAgeDays": 14,
|
|
"useRelay": true,
|
|
"showAllRelayFeeds": false,
|
|
"previewServiceEnabled": true,
|
|
"previewServiceURL": "https://preview.org-social.org/"
|
|
])
|
|
}
|
|
|
|
var body: some Scene {
|
|
WindowGroup {
|
|
RootView()
|
|
}
|
|
}
|
|
}
|