diff --git a/apple/OmnivoreKit/Sources/App/Views/SelfHostSettingsView.swift b/apple/OmnivoreKit/Sources/App/Views/SelfHostSettingsView.swift index 06d7eea87..d9a0c0ba7 100644 --- a/apple/OmnivoreKit/Sources/App/Views/SelfHostSettingsView.swift +++ b/apple/OmnivoreKit/Sources/App/Views/SelfHostSettingsView.swift @@ -10,9 +10,9 @@ } struct SelfHostSettingsView: View { - @State var apiServerAddress = "" - @State var webServerAddress = "" - @State var ttsServerAddress = "" + @State var apiServerAddress = UserDefaults.standard.string(forKey: AppEnvironmentUserDefaultKey.serverBaseURL.rawValue) ?? "" + @State var webServerAddress = UserDefaults.standard.string(forKey: AppEnvironmentUserDefaultKey.webAppBaseURL.rawValue) ?? "" + @State var ttsServerAddress = UserDefaults.standard.string(forKey: AppEnvironmentUserDefaultKey.ttsBaseURL.rawValue) ?? "" @State var showConfirmAlert = false @@ -39,16 +39,22 @@ Section("API Server Base URL") { TextField("URL", text: $apiServerAddress, prompt: Text("https://api-prod.omnivore.app")) .keyboardType(.URL) + .autocorrectionDisabled(true) + .textInputAutocapitalization(.never) } Section("Web Server URL") { TextField("URL", text: $webServerAddress, prompt: Text("https://omnivore.app")) .keyboardType(.URL) + .autocorrectionDisabled(true) + .textInputAutocapitalization(.never) } Section("Text-to-speech Server URL") { TextField("URL", text: $ttsServerAddress, prompt: Text("https://tts.omnivore.app")) .keyboardType(.URL) + .autocorrectionDisabled(true) + .textInputAutocapitalization(.never) } Section { diff --git a/apple/OmnivoreKit/Sources/Models/AppEnvironment.swift b/apple/OmnivoreKit/Sources/Models/AppEnvironment.swift index d29e3d8a8..92016510b 100644 --- a/apple/OmnivoreKit/Sources/Models/AppEnvironment.swift +++ b/apple/OmnivoreKit/Sources/Models/AppEnvironment.swift @@ -32,7 +32,7 @@ private let devWebURL = "https://web-dev.omnivore.app" private let demoWebURL = "https://demo.omnivore.app" private let prodWebURL = "https://omnivore.app" -private enum AppEnvironmentUserDefaultKey: String { +public enum AppEnvironmentUserDefaultKey: String { case serverBaseURL = "AppEnvironment_serverBaseURL" case webAppBaseURL = "AppEnvironment_webAppBaseURL" case ttsBaseURL = "AppEnvironment_ttsBaseURL" @@ -40,9 +40,18 @@ private enum AppEnvironmentUserDefaultKey: String { public extension AppEnvironment { static func setCustom(serverBaseURL: String, webAppBaseURL: String, ttsBaseURL: String) { - UserDefaults.standard.set(serverBaseURL, forKey: AppEnvironmentUserDefaultKey.serverBaseURL.rawValue) - UserDefaults.standard.set(webAppBaseURL, forKey: AppEnvironmentUserDefaultKey.webAppBaseURL.rawValue) - UserDefaults.standard.set(ttsBaseURL, forKey: AppEnvironmentUserDefaultKey.ttsBaseURL.rawValue) + UserDefaults.standard.set( + serverBaseURL.trimmingCharacters(in: CharacterSet.whitespacesAndNewlines), + forKey: AppEnvironmentUserDefaultKey.serverBaseURL.rawValue + ) + UserDefaults.standard.set( + webAppBaseURL.trimmingCharacters(in: CharacterSet.whitespacesAndNewlines), + forKey: AppEnvironmentUserDefaultKey.webAppBaseURL.rawValue + ) + UserDefaults.standard.set( + ttsBaseURL.trimmingCharacters(in: CharacterSet.whitespacesAndNewlines), + forKey: AppEnvironmentUserDefaultKey.ttsBaseURL.rawValue + ) } var graphqlPath: String { diff --git a/packages/db/setup.sh b/packages/db/setup.sh index d91340cab..83d1cd09f 100755 --- a/packages/db/setup.sh +++ b/packages/db/setup.sh @@ -1,9 +1,9 @@ #!/bin/bash -psql --host $PG_HOST -U $PG_USER -d $PG_DB -c "CREATE USER app_user WITH PASSWORD 'app_pass';" +psql --host $PG_HOST -U $PG_USER -d $PG_DB -c "CREATE USER app_user WITH PASSWORD 'app_pass';" || true echo "created app_user" yarn workspace @omnivore/db migrate -psql --host $PG_HOST -U $PG_USER -d $PG_DB -c "GRANT omnivore_user TO app_user;" +psql --host $PG_HOST -U $PG_USER -d $PG_DB -c "GRANT omnivore_user TO app_user;" || true echo "granted omnivore_user to app_user" # create demo user with email: demo@omnivore.app, password: demo