Compare commits
5 Commits
f448090c2a
...
b28792eb29
Author | SHA1 | Date |
---|---|---|
Shadowfacts | b28792eb29 | |
Shadowfacts | 9c3be68e1c | |
Shadowfacts | df9ce81060 | |
Shadowfacts | 173eda1757 | |
Shadowfacts | b2b15b8b6e |
|
@ -58,7 +58,7 @@ public final class ComposeController: ViewController {
|
|||
private var isDisappearing = false
|
||||
private var userConfirmedDelete = false
|
||||
|
||||
var isPosting: Bool {
|
||||
public var isPosting: Bool {
|
||||
poster != nil
|
||||
}
|
||||
|
||||
|
@ -424,6 +424,7 @@ public final class ComposeController: ViewController {
|
|||
// otherwise all Buttons in the nav bar are made semibold
|
||||
.font(.system(size: 17, weight: .regular))
|
||||
}
|
||||
.disabled(controller.isPosting)
|
||||
.confirmationDialog("Are you sure?", isPresented: $controller.isShowingSaveDraftSheet) {
|
||||
// edit drafts can't be saved
|
||||
if draft.editedStatusID == nil {
|
||||
|
|
|
@ -11,9 +11,6 @@ import TuskerComponents
|
|||
|
||||
class ToolbarController: ViewController {
|
||||
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
|
||||
|
||||
|
@ -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<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 {
|
||||
let domain = composeController.mastodonController.accountInfo!.instanceURL.host!
|
||||
return MenuPicker(selection: $draft.localOnly, options: [
|
||||
|
|
|
@ -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() {
|
||||
}
|
||||
|
||||
|
|
|
@ -21,7 +21,12 @@ public struct Mention: Codable, Sendable {
|
|||
self.username = try container.decode(String.self, forKey: .username)
|
||||
self.acct = try container.decode(String.self, forKey: .acct)
|
||||
self.id = try container.decode(String.self, forKey: .id)
|
||||
self.url = try container.decode(WebURL.self, forKey: .url)
|
||||
do {
|
||||
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) {
|
||||
|
|
|
@ -88,7 +88,7 @@ class ComposeHostingController: UIHostingController<ComposeHostingController.Vie
|
|||
config.contentType = Preferences.shared.statusContentType
|
||||
config.requireAttachmentDescriptions = Preferences.shared.requireAttachmentDescriptions
|
||||
|
||||
config.dismiss = { [unowned self] in self.dismiss(mode: $0) }
|
||||
config.dismiss = { [weak self] in self?.dismiss(mode: $0) }
|
||||
config.presentAssetPicker = { [unowned self] in self.presentAssetPicker(completion: $0) }
|
||||
config.presentDrawing = { [unowned self] in self.presentDrawing($0, completion: $1) }
|
||||
config.userActivityForDraft = { [unowned self] in
|
||||
|
@ -144,7 +144,9 @@ class ComposeHostingController: UIHostingController<ComposeHostingController.Vie
|
|||
// MARK: Duckable
|
||||
|
||||
func duckableViewControllerShouldDuck() -> DuckAttemptAction {
|
||||
if controller.draft.hasContent {
|
||||
if controller.isPosting {
|
||||
return .block
|
||||
} else if controller.draft.hasContent {
|
||||
return .duck
|
||||
} else {
|
||||
return .dismiss
|
||||
|
|
|
@ -125,7 +125,7 @@ private func captureError(_ error: Client.Error, in mastodonController: Mastodon
|
|||
return
|
||||
}
|
||||
if let code = event.tags!["response_code"],
|
||||
code == "401" || code == "403" || code == "404" || code == "502" || code == "503" {
|
||||
code == "401" || code == "403" || code == "404" || code == "422" || code == "500" || code == "502" || code == "503" {
|
||||
return
|
||||
}
|
||||
switch mastodonController.instanceFeatures.instanceType {
|
||||
|
|
Loading…
Reference in New Issue