Add hint if the server post options are overridden (#1679)

If the content settings specify their own post settings and override the
instance settings, a hint (and link to the content settings) is added to the
instance settings (infos) since that setting might introduce confusion (As
happened in #1677).
This commit is contained in:
Paul Schuetz 2023-11-19 08:10:53 +01:00 committed by GitHub
parent 8bf36709ea
commit 12d92ab1ec
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 46 additions and 0 deletions

View file

@ -98,6 +98,7 @@ struct AccountSettingsView: View {
}
.sheet(isPresented: $isEditingAccount, content: {
EditAccountView()
.environment(\.contentSettingsFactory, AnyView(ContentSettingsView()))
})
.sheet(isPresented: $isEditingFilters, content: {
FiltersListView()

View file

@ -12723,6 +12723,23 @@
}
}
},
"account.edit.post-settings.content-settings-reference" : {
"extractionState" : "manual",
"localizations" : {
"de" : {
"stringUnit" : {
"state" : "translated",
"value" : "Achtung: Diese Optionen werden durch die globalen Inhaltseinstellungen überschrieben"
}
},
"en" : {
"stringUnit" : {
"state" : "translated",
"value" : "Warning: These settings are overwritten by the global content settings"
}
}
}
},
"account.edit.post-settings.privacy" : {
"extractionState" : "manual",
"localizations" : {

View file

@ -19,6 +19,7 @@ let package = Package(
.package(name: "Network", path: "../Network"),
.package(name: "Models", path: "../Models"),
.package(name: "Status", path: "../Status"),
.package(name: "Env", path: "../Env"),
],
targets: [
.target(
@ -27,6 +28,7 @@ let package = Package(
.product(name: "Network", package: "Network"),
.product(name: "Models", package: "Models"),
.product(name: "Status", package: "Status"),
.product(name: "Env", package: "Env"),
],
swiftSettings: [
.enableExperimentalFeature("StrictConcurrency"),

View file

@ -1,6 +1,7 @@
import DesignSystem
import Models
import Network
import Env
import SwiftUI
@MainActor
@ -8,8 +9,11 @@ public struct EditAccountView: View {
@Environment(\.dismiss) private var dismiss
@Environment(Client.self) private var client
@Environment(Theme.self) private var theme
@Environment(UserPreferences.self) private var userPrefs
@Environment(\.contentSettingsFactory) private var contentSettings
@State private var viewModel = EditAccountViewModel()
@State private var showContentSettings = false
public init() {}
@ -72,6 +76,19 @@ public struct EditAccountView: View {
private var postSettingsSection: some View {
Section("account.edit.post-settings.section-title") {
if !userPrefs.useInstanceContentSettings {
HStack {
Button("account.edit.post-settings.content-settings-reference") {showContentSettings.toggle()}
.buttonStyle(.plain)
.navigationDestination(isPresented: $showContentSettings) {
contentSettings
}
Spacer()
Image(systemName: "chevron.right")
.font(.caption)
}
.foregroundStyle(Color.accentColor)
}
Picker(selection: $viewModel.postPrivacy) {
ForEach(Models.Visibility.supportDefault, id: \.rawValue) { privacy in
Text(privacy.title).tag(privacy)

View file

@ -29,6 +29,10 @@ private struct IndentationLevel: EnvironmentKey {
static let defaultValue: UInt = 0
}
private struct ContentSettingsFactory: EnvironmentKey {
static let defaultValue: AnyView = AnyView(EmptyView())
}
public extension EnvironmentValues {
var isSecondaryColumn: Bool {
get { self[SecondaryColumnKey.self] }
@ -64,4 +68,9 @@ public extension EnvironmentValues {
get { self[IndentationLevel.self] }
set { self[IndentationLevel.self] = newValue }
}
var contentSettingsFactory: AnyView {
get { self[ContentSettingsFactory.self] }
set { self[ContentSettingsFactory.self] = newValue }
}
}