From 28e368796a629f4c579449d8e2d401c42089cb62 Mon Sep 17 00:00:00 2001 From: Paulo Castellano Date: Sat, 9 May 2026 14:16:48 -0300 Subject: [PATCH] fix(tiktok): auto-switch content_type when attached media changes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The TikTok platform tile was getting silently disabled when the user attached images before selecting TikTok: a fresh post defaults TikTok to tiktok_video, the compliance check rejects images for video posts, and platformIssues marks the tile as un-clickable. Watch the media ref. If the first attached item is an image and the TikTok post-platform's content_type is still tiktok_video (or vice versa for video media on tiktok_photo), flip the content_type to match. The variant picker inside TikTokSettings can still override afterwards; this only covers the gap between adding media and opening the panel. Reproducer: new post → attach image → click TikTok tile → previously disabled with 'Only videos are allowed for this format', now enabled and content_type lands on tiktok_photo. --- resources/js/pages/posts/Edit.vue | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/resources/js/pages/posts/Edit.vue b/resources/js/pages/posts/Edit.vue index 80dbe4c2..c83c6089 100644 --- a/resources/js/pages/posts/Edit.vue +++ b/resources/js/pages/posts/Edit.vue @@ -392,6 +392,28 @@ const triggerAutosave = () => { } }; +// Auto-switch TikTok content_type to match the attached media. Without this, +// a fresh post defaults TikTok to tiktok_video, so attaching images first +// disables the TikTok tile (compliance check rejects images for video posts). +// User can still override via the variant picker in TikTokSettings. +watch(media, () => { + if (media.value.length === 0) return; + + const first = media.value[0]; + const isVideo = first.type === 'video' || first.mime_type?.startsWith('video/'); + const isImage = first.type === 'image' || first.mime_type?.startsWith('image/'); + const target = isVideo ? 'tiktok_video' : isImage ? 'tiktok_photo' : null; + if (!target) return; + + for (const pp of post.value.post_platforms) { + if (pp.platform !== Platform.TikTok) continue; + const current = platformContentTypes.value[pp.id]; + if (current && current !== target && (current === 'tiktok_video' || current === 'tiktok_photo')) { + platformContentTypes.value = { ...platformContentTypes.value, [pp.id]: target }; + } + } +}, { deep: true }); + watch([content, media, selectedPlatformIds, scheduledDateTime, selectedLabelIds, platformMeta, platformContentTypes], triggerAutosave, { deep: true }); onUnmounted(() => {