From 39c8162931c0f27eeb01c4438b3845d72bf079ae Mon Sep 17 00:00:00 2001 From: Shadowfacts Date: Mon, 7 Sep 2020 14:43:39 -0400 Subject: [PATCH] Prevent attempting to add an attachment when the possibility would be invalid --- Tusker/Screens/Compose/ComposeAttachmentsList.swift | 3 +-- Tusker/Screens/Compose/ComposeHostingController.swift | 3 ++- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Tusker/Screens/Compose/ComposeAttachmentsList.swift b/Tusker/Screens/Compose/ComposeAttachmentsList.swift index 7c79f2fc..584fc397 100644 --- a/Tusker/Screens/Compose/ComposeAttachmentsList.swift +++ b/Tusker/Screens/Compose/ComposeAttachmentsList.swift @@ -95,8 +95,7 @@ struct ComposeAttachmentsList: View { case .pleroma: return true case .mastodon: - // todo: this technically allows invalid image/video combinations - return draft.attachments.count < 4 + return draft.attachments.count < 4 && draft.attachments.allSatisfy { $0.data.type == .image } } } diff --git a/Tusker/Screens/Compose/ComposeHostingController.swift b/Tusker/Screens/Compose/ComposeHostingController.swift index 2fca4e61..d8fe99c5 100644 --- a/Tusker/Screens/Compose/ComposeHostingController.swift +++ b/Tusker/Screens/Compose/ComposeHostingController.swift @@ -199,7 +199,8 @@ class ComposeHostingController: UIHostingController { case .pleroma: return true case .mastodon: - // todo: this technically allows invalid video/image combinations + guard draft.attachments.allSatisfy({ $0.data.type == .image }) else { return false } + // todo: if providers are videos, this technically allows invalid video/image combinations return itemProviders.count + draft.attachments.count <= 4 } }