From 2961793e8765fdaba25da70d22d63c5a81e6410c Mon Sep 17 00:00:00 2001 From: Thomas Ricouard Date: Mon, 9 Jan 2023 20:46:01 +0100 Subject: [PATCH] Support server side default post visibility --- IceCubesApp/App/Tabs/ExploreTab.swift | 4 +++- IceCubesApp/App/Tabs/NotificationTab.swift | 3 ++- IceCubesApp/App/Tabs/Timeline/TimelineTab.swift | 3 ++- Packages/Account/Sources/Account/AccountDetailView.swift | 4 +++- 4 files changed, 10 insertions(+), 4 deletions(-) diff --git a/IceCubesApp/App/Tabs/ExploreTab.swift b/IceCubesApp/App/Tabs/ExploreTab.swift index 0fe5ae49..a71449c2 100644 --- a/IceCubesApp/App/Tabs/ExploreTab.swift +++ b/IceCubesApp/App/Tabs/ExploreTab.swift @@ -7,6 +7,7 @@ import Env import Network struct ExploreTab: View { + @EnvironmentObject private var preferences: UserPreferences @EnvironmentObject private var currentAccount: CurrentAccount @EnvironmentObject private var client: Client @StateObject private var routeurPath = RouterPath() @@ -18,7 +19,8 @@ struct ExploreTab: View { .withAppRouteur() .withSheetDestinations(sheetDestinations: $routeurPath.presentedSheet) .toolbar { - statusEditorToolbarItem(routeurPath: routeurPath, visibility: .pub) + statusEditorToolbarItem(routeurPath: routeurPath, + visibility: preferences.serverPreferences?.postVisibility ?? .pub) ToolbarItem(placement: .navigationBarLeading) { AppAccountsSelectorView(routeurPath: routeurPath) } diff --git a/IceCubesApp/App/Tabs/NotificationTab.swift b/IceCubesApp/App/Tabs/NotificationTab.swift index 6c85bbc7..d5e22fd7 100644 --- a/IceCubesApp/App/Tabs/NotificationTab.swift +++ b/IceCubesApp/App/Tabs/NotificationTab.swift @@ -18,7 +18,8 @@ struct NotificationsTab: View { .withAppRouteur() .withSheetDestinations(sheetDestinations: $routeurPath.presentedSheet) .toolbar { - statusEditorToolbarItem(routeurPath: routeurPath, visibility: .pub) + statusEditorToolbarItem(routeurPath: routeurPath, + visibility: userPreferences.serverPreferences?.postVisibility ?? .pub) ToolbarItem(placement: .navigationBarLeading) { AppAccountsSelectorView(routeurPath: routeurPath) } diff --git a/IceCubesApp/App/Tabs/Timeline/TimelineTab.swift b/IceCubesApp/App/Tabs/Timeline/TimelineTab.swift index 07684204..1defdac8 100644 --- a/IceCubesApp/App/Tabs/Timeline/TimelineTab.swift +++ b/IceCubesApp/App/Tabs/Timeline/TimelineTab.swift @@ -127,7 +127,8 @@ struct TimelineTab: View { ToolbarItem(placement: .navigationBarLeading) { AppAccountsSelectorView(routeurPath: routeurPath) } - statusEditorToolbarItem(routeurPath: routeurPath, visibility: .pub) + statusEditorToolbarItem(routeurPath: routeurPath, + visibility: preferences.serverPreferences?.postVisibility ?? .pub) } else { ToolbarItem(placement: .navigationBarTrailing) { addAccountButton diff --git a/Packages/Account/Sources/Account/AccountDetailView.swift b/Packages/Account/Sources/Account/AccountDetailView.swift index 1754be85..585001ee 100644 --- a/Packages/Account/Sources/Account/AccountDetailView.swift +++ b/Packages/Account/Sources/Account/AccountDetailView.swift @@ -10,6 +10,7 @@ public struct AccountDetailView: View { @Environment(\.redactionReasons) private var reasons @EnvironmentObject private var watcher: StreamWatcher @EnvironmentObject private var currentAccount: CurrentAccount + @EnvironmentObject private var preferences: UserPreferences @EnvironmentObject private var theme: Theme @EnvironmentObject private var client: Client @EnvironmentObject private var routeurPath: RouterPath @@ -334,7 +335,8 @@ public struct AccountDetailView: View { Section(account.acct) { if !viewModel.isCurrentUser { Button { - routeurPath.presentedSheet = .mentionStatusEditor(account: account, visibility: .pub) + routeurPath.presentedSheet = .mentionStatusEditor(account: account, + visibility: preferences.serverPreferences?.postVisibility ?? .pub) } label: { Label("Mention", systemImage: "at") }