Compare commits

..

No commits in common. "b28792eb295bdf56842a6feca3eceb7c09d89617" and "f448090c2a990a534443c54d238b12d89ddb030c" have entirely different histories.

6 changed files with 9 additions and 34 deletions

View File

@ -58,7 +58,7 @@ public final class ComposeController: ViewController {
private var isDisappearing = false private var isDisappearing = false
private var userConfirmedDelete = false private var userConfirmedDelete = false
public var isPosting: Bool { var isPosting: Bool {
poster != nil poster != nil
} }
@ -424,7 +424,6 @@ public final class ComposeController: ViewController {
// otherwise all Buttons in the nav bar are made semibold // otherwise all Buttons in the nav bar are made semibold
.font(.system(size: 17, weight: .regular)) .font(.system(size: 17, weight: .regular))
} }
.disabled(controller.isPosting)
.confirmationDialog("Are you sure?", isPresented: $controller.isShowingSaveDraftSheet) { .confirmationDialog("Are you sure?", isPresented: $controller.isShowingSaveDraftSheet) {
// edit drafts can't be saved // edit drafts can't be saved
if draft.editedStatusID == nil { if draft.editedStatusID == nil {

View File

@ -11,6 +11,9 @@ 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
@ -53,7 +56,7 @@ class ToolbarController: ViewController {
HStack(spacing: 0) { HStack(spacing: 0) {
cwButton cwButton
MenuPicker(selection: $draft.visibility, options: visibilityOptions, buttonStyle: .iconOnly) MenuPicker(selection: $draft.visibility, options: ToolbarController.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)
@ -118,18 +121,6 @@ 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,14 +147,6 @@ 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() {
} }

View File

@ -21,12 +21,7 @@ public struct Mention: Codable, Sendable {
self.username = try container.decode(String.self, forKey: .username) self.username = try container.decode(String.self, forKey: .username)
self.acct = try container.decode(String.self, forKey: .acct) self.acct = try container.decode(String.self, forKey: .acct)
self.id = try container.decode(String.self, forKey: .id) self.id = try container.decode(String.self, forKey: .id)
do {
self.url = try container.decode(WebURL.self, forKey: .url) self.url = try container.decode(WebURL.self, forKey: .url)
} catch {
let s = try? container.decode(String.self, forKey: .url)
throw DecodingError.dataCorruptedError(forKey: .url, in: container, debugDescription: "Could not decode URL '\(s ?? "<failed to decode string>")'")
}
} }
public init(url: WebURL, username: String, acct: String, id: String) { public init(url: WebURL, username: String, acct: String, id: String) {

View File

@ -88,7 +88,7 @@ class ComposeHostingController: UIHostingController<ComposeHostingController.Vie
config.contentType = Preferences.shared.statusContentType config.contentType = Preferences.shared.statusContentType
config.requireAttachmentDescriptions = Preferences.shared.requireAttachmentDescriptions config.requireAttachmentDescriptions = Preferences.shared.requireAttachmentDescriptions
config.dismiss = { [weak self] in self?.dismiss(mode: $0) } config.dismiss = { [unowned self] in self.dismiss(mode: $0) }
config.presentAssetPicker = { [unowned self] in self.presentAssetPicker(completion: $0) } config.presentAssetPicker = { [unowned self] in self.presentAssetPicker(completion: $0) }
config.presentDrawing = { [unowned self] in self.presentDrawing($0, completion: $1) } config.presentDrawing = { [unowned self] in self.presentDrawing($0, completion: $1) }
config.userActivityForDraft = { [unowned self] in config.userActivityForDraft = { [unowned self] in
@ -144,9 +144,7 @@ class ComposeHostingController: UIHostingController<ComposeHostingController.Vie
// MARK: Duckable // MARK: Duckable
func duckableViewControllerShouldDuck() -> DuckAttemptAction { func duckableViewControllerShouldDuck() -> DuckAttemptAction {
if controller.isPosting { if controller.draft.hasContent {
return .block
} else if controller.draft.hasContent {
return .duck return .duck
} else { } else {
return .dismiss return .dismiss

View File

@ -125,7 +125,7 @@ private func captureError(_ error: Client.Error, in mastodonController: Mastodon
return return
} }
if let code = event.tags!["response_code"], if let code = event.tags!["response_code"],
code == "401" || code == "403" || code == "404" || code == "422" || code == "500" || code == "502" || code == "503" { code == "401" || code == "403" || code == "404" || code == "502" || code == "503" {
return return
} }
switch mastodonController.instanceFeatures.instanceType { switch mastodonController.instanceFeatures.instanceType {