Ensure app environment is configured

This can happen if a user sets a custom self hosting environment,
then deletes and re-installs the app.
This commit is contained in:
Jackson Harper
2024-01-04 10:59:36 +08:00
parent 8a288ffe5f
commit 4689b5325f
2 changed files with 12 additions and 1 deletions

View File

@ -49,7 +49,7 @@ struct InnerRootView: View {
@ObservedObject var viewModel: RootViewModel @ObservedObject var viewModel: RootViewModel
@ViewBuilder private var innerBody: some View { @ViewBuilder private var innerBody: some View {
if authenticator.isLoggedIn { if authenticator.isLoggedIn, dataService.appEnvironment.environmentConfigured {
PrimaryContentView() PrimaryContentView()
.task { .task {
try? await dataService.syncOfflineItemsWithServerIfNeeded() try? await dataService.syncOfflineItemsWithServerIfNeeded()

View File

@ -54,6 +54,17 @@ public extension AppEnvironment {
) )
} }
var environmentConfigured: Bool {
if self == .custom {
if let str = UserDefaults.standard.string(forKey: AppEnvironmentUserDefaultKey.webAppBaseURL.rawValue), let url = URL(string: str) {
return true
} else {
return false
}
}
return true
}
var graphqlPath: String { var graphqlPath: String {
"\(serverBaseURL.absoluteString)/api/graphql" "\(serverBaseURL.absoluteString)/api/graphql"
} }