Fix Post button always being disabled when require attachment descriptions is enabled
Also fix post button state not updating when description edited Closes #371
This commit is contained in:
parent
06855420da
commit
074a296a68
|
@ -20,15 +20,17 @@ class AttachmentsListController: ViewController {
|
||||||
|
|
||||||
private var requiresAttachmentDescriptions: Bool {
|
private var requiresAttachmentDescriptions: Bool {
|
||||||
if parent.config.requireAttachmentDescriptions {
|
if parent.config.requireAttachmentDescriptions {
|
||||||
return draft.attachments.allSatisfy {
|
if draft.attachments.isEmpty {
|
||||||
!$0.attachmentDescription.isEmpty
|
return false
|
||||||
|
} else {
|
||||||
|
return !parent.attachmentsMissingDescriptions.isEmpty
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private var validAttachmentCombination: Bool {
|
var validAttachmentCombination: Bool {
|
||||||
if !parent.mastodonController.instanceFeatures.mastodonAttachmentRestrictions {
|
if !parent.mastodonController.instanceFeatures.mastodonAttachmentRestrictions {
|
||||||
return true
|
return true
|
||||||
} else if draft.attachments.contains(where: { $0.data.type == .video }) &&
|
} else if draft.attachments.contains(where: { $0.data.type == .video }) &&
|
||||||
|
@ -139,6 +141,13 @@ class AttachmentsListController: ViewController {
|
||||||
.onDrag {
|
.onDrag {
|
||||||
NSItemProvider(object: attachment)
|
NSItemProvider(object: attachment)
|
||||||
}
|
}
|
||||||
|
.onReceive(attachment.$attachmentDescription.map(\.isEmpty).removeDuplicates()) { isEmpty in
|
||||||
|
if isEmpty {
|
||||||
|
controller.parent.attachmentsMissingDescriptions.insert(attachment.id)
|
||||||
|
} else {
|
||||||
|
controller.parent.attachmentsMissingDescriptions.remove(attachment.id)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
.onMove(perform: controller.moveAttachments)
|
.onMove(perform: controller.moveAttachments)
|
||||||
.onDelete(perform: controller.deleteAttachments)
|
.onDelete(perform: controller.deleteAttachments)
|
||||||
|
|
|
@ -32,6 +32,9 @@ public final class ComposeController: ViewController {
|
||||||
@Published var toolbarController: ToolbarController!
|
@Published var toolbarController: ToolbarController!
|
||||||
@Published var attachmentsListController: AttachmentsListController!
|
@Published var attachmentsListController: AttachmentsListController!
|
||||||
|
|
||||||
|
// this property is here rather than on the AttachmentsListController so that the ComposeView
|
||||||
|
// updates when it changes, because changes to it may alter postButtonEnabled
|
||||||
|
@Published var attachmentsMissingDescriptions = Set<UUID>()
|
||||||
@Published var contentWarningBecomeFirstResponder = false
|
@Published var contentWarningBecomeFirstResponder = false
|
||||||
@Published var mainComposeTextViewBecomeFirstResponder = false
|
@Published var mainComposeTextViewBecomeFirstResponder = false
|
||||||
@Published var currentInput: (any ComposeInput)? = nil
|
@Published var currentInput: (any ComposeInput)? = nil
|
||||||
|
|
Loading…
Reference in New Issue