Disallow posting direct messages on Pixelfed

This commit is contained in:
Shadowfacts 2023-09-09 11:07:27 -04:00
parent f448090c2a
commit b2b15b8b6e
2 changed files with 21 additions and 4 deletions

View File

@ -11,9 +11,6 @@ import TuskerComponents
class ToolbarController: ViewController { class ToolbarController: ViewController {
static let height: CGFloat = 44 static let height: CGFloat = 44
private static let visibilityOptions: [MenuPicker<Pachyderm.Visibility>.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 unowned let parent: ComposeController
@ -56,7 +53,7 @@ class ToolbarController: ViewController {
HStack(spacing: 0) { HStack(spacing: 0) {
cwButton 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 // the button has a bunch of extra space by default, but combined with what we add it's too much
.padding(.horizontal, -8) .padding(.horizontal, -8)
.disabled(draft.editedStatusID != nil) .disabled(draft.editedStatusID != nil)
@ -121,6 +118,18 @@ class ToolbarController: ViewController {
.hoverEffect() .hoverEffect()
} }
private var visibilityOptions: [MenuPicker<Pachyderm.Visibility>.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 { private var localOnlyPicker: some View {
let domain = composeController.mastodonController.accountInfo!.instanceURL.host! let domain = composeController.mastodonController.accountInfo!.instanceURL.host!
return MenuPicker(selection: $draft.localOnly, options: [ return MenuPicker(selection: $draft.localOnly, options: [

View File

@ -147,6 +147,14 @@ public class InstanceFeatures: ObservableObject {
instanceType.isPleroma(.akkoma(nil)) instanceType.isPleroma(.akkoma(nil))
} }
public var composeDirectStatuses: Bool {
if case .pixelfed = instanceType {
return false
} else {
return true
}
}
public init() { public init() {
} }