From b2b15b8b6ed005d122fb6420e73fe55ac12b10dd Mon Sep 17 00:00:00 2001 From: Shadowfacts Date: Sat, 9 Sep 2023 11:07:27 -0400 Subject: [PATCH] Disallow posting direct messages on Pixelfed --- .../Controllers/ToolbarController.swift | 17 +++++++++++++---- .../InstanceFeatures/InstanceFeatures.swift | 8 ++++++++ 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/Packages/ComposeUI/Sources/ComposeUI/Controllers/ToolbarController.swift b/Packages/ComposeUI/Sources/ComposeUI/Controllers/ToolbarController.swift index ee37c246..b96d2c6f 100644 --- a/Packages/ComposeUI/Sources/ComposeUI/Controllers/ToolbarController.swift +++ b/Packages/ComposeUI/Sources/ComposeUI/Controllers/ToolbarController.swift @@ -11,9 +11,6 @@ import TuskerComponents class ToolbarController: ViewController { static let height: CGFloat = 44 - private static let visibilityOptions: [MenuPicker.Option] = Pachyderm.Visibility.allCases.map { vis in - .init(value: vis, title: vis.displayName, subtitle: vis.subtitle, image: UIImage(systemName: vis.unfilledImageName), accessibilityLabel: "Visibility: \(vis.displayName)") - } unowned let parent: ComposeController @@ -56,7 +53,7 @@ class ToolbarController: ViewController { HStack(spacing: 0) { cwButton - MenuPicker(selection: $draft.visibility, options: ToolbarController.visibilityOptions, buttonStyle: .iconOnly) + MenuPicker(selection: $draft.visibility, options: visibilityOptions, buttonStyle: .iconOnly) // the button has a bunch of extra space by default, but combined with what we add it's too much .padding(.horizontal, -8) .disabled(draft.editedStatusID != nil) @@ -121,6 +118,18 @@ class ToolbarController: ViewController { .hoverEffect() } + private var visibilityOptions: [MenuPicker.Option] { + let visibilities: [Pachyderm.Visibility] + if !controller.parent.mastodonController.instanceFeatures.composeDirectStatuses { + visibilities = [.public, .unlisted, .private] + } else { + visibilities = Pachyderm.Visibility.allCases + } + return visibilities.map { vis in + .init(value: vis, title: vis.displayName, subtitle: vis.subtitle, image: UIImage(systemName: vis.unfilledImageName), accessibilityLabel: "Visibility: \(vis.displayName)") + } + } + private var localOnlyPicker: some View { let domain = composeController.mastodonController.accountInfo!.instanceURL.host! return MenuPicker(selection: $draft.localOnly, options: [ diff --git a/Packages/InstanceFeatures/Sources/InstanceFeatures/InstanceFeatures.swift b/Packages/InstanceFeatures/Sources/InstanceFeatures/InstanceFeatures.swift index ab2bc49b..8f4f0c6b 100644 --- a/Packages/InstanceFeatures/Sources/InstanceFeatures/InstanceFeatures.swift +++ b/Packages/InstanceFeatures/Sources/InstanceFeatures/InstanceFeatures.swift @@ -147,6 +147,14 @@ public class InstanceFeatures: ObservableObject { instanceType.isPleroma(.akkoma(nil)) } + public var composeDirectStatuses: Bool { + if case .pixelfed = instanceType { + return false + } else { + return true + } + } + public init() { }