Support server side default post visibility

This commit is contained in:
Thomas Ricouard 2023-01-09 20:46:01 +01:00
parent dc223171b3
commit 2961793e87
4 changed files with 10 additions and 4 deletions

View file

@ -7,6 +7,7 @@ import Env
import Network import Network
struct ExploreTab: View { struct ExploreTab: View {
@EnvironmentObject private var preferences: UserPreferences
@EnvironmentObject private var currentAccount: CurrentAccount @EnvironmentObject private var currentAccount: CurrentAccount
@EnvironmentObject private var client: Client @EnvironmentObject private var client: Client
@StateObject private var routeurPath = RouterPath() @StateObject private var routeurPath = RouterPath()
@ -18,7 +19,8 @@ struct ExploreTab: View {
.withAppRouteur() .withAppRouteur()
.withSheetDestinations(sheetDestinations: $routeurPath.presentedSheet) .withSheetDestinations(sheetDestinations: $routeurPath.presentedSheet)
.toolbar { .toolbar {
statusEditorToolbarItem(routeurPath: routeurPath, visibility: .pub) statusEditorToolbarItem(routeurPath: routeurPath,
visibility: preferences.serverPreferences?.postVisibility ?? .pub)
ToolbarItem(placement: .navigationBarLeading) { ToolbarItem(placement: .navigationBarLeading) {
AppAccountsSelectorView(routeurPath: routeurPath) AppAccountsSelectorView(routeurPath: routeurPath)
} }

View file

@ -18,7 +18,8 @@ struct NotificationsTab: View {
.withAppRouteur() .withAppRouteur()
.withSheetDestinations(sheetDestinations: $routeurPath.presentedSheet) .withSheetDestinations(sheetDestinations: $routeurPath.presentedSheet)
.toolbar { .toolbar {
statusEditorToolbarItem(routeurPath: routeurPath, visibility: .pub) statusEditorToolbarItem(routeurPath: routeurPath,
visibility: userPreferences.serverPreferences?.postVisibility ?? .pub)
ToolbarItem(placement: .navigationBarLeading) { ToolbarItem(placement: .navigationBarLeading) {
AppAccountsSelectorView(routeurPath: routeurPath) AppAccountsSelectorView(routeurPath: routeurPath)
} }

View file

@ -127,7 +127,8 @@ struct TimelineTab: View {
ToolbarItem(placement: .navigationBarLeading) { ToolbarItem(placement: .navigationBarLeading) {
AppAccountsSelectorView(routeurPath: routeurPath) AppAccountsSelectorView(routeurPath: routeurPath)
} }
statusEditorToolbarItem(routeurPath: routeurPath, visibility: .pub) statusEditorToolbarItem(routeurPath: routeurPath,
visibility: preferences.serverPreferences?.postVisibility ?? .pub)
} else { } else {
ToolbarItem(placement: .navigationBarTrailing) { ToolbarItem(placement: .navigationBarTrailing) {
addAccountButton addAccountButton

View file

@ -10,6 +10,7 @@ public struct AccountDetailView: View {
@Environment(\.redactionReasons) private var reasons @Environment(\.redactionReasons) private var reasons
@EnvironmentObject private var watcher: StreamWatcher @EnvironmentObject private var watcher: StreamWatcher
@EnvironmentObject private var currentAccount: CurrentAccount @EnvironmentObject private var currentAccount: CurrentAccount
@EnvironmentObject private var preferences: UserPreferences
@EnvironmentObject private var theme: Theme @EnvironmentObject private var theme: Theme
@EnvironmentObject private var client: Client @EnvironmentObject private var client: Client
@EnvironmentObject private var routeurPath: RouterPath @EnvironmentObject private var routeurPath: RouterPath
@ -334,7 +335,8 @@ public struct AccountDetailView: View {
Section(account.acct) { Section(account.acct) {
if !viewModel.isCurrentUser { if !viewModel.isCurrentUser {
Button { Button {
routeurPath.presentedSheet = .mentionStatusEditor(account: account, visibility: .pub) routeurPath.presentedSheet = .mentionStatusEditor(account: account,
visibility: preferences.serverPreferences?.postVisibility ?? .pub)
} label: { } label: {
Label("Mention", systemImage: "at") Label("Mention", systemImage: "at")
} }