fix(tiktok): auto-switch content_type when attached media changes

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.
This commit is contained in:
Paulo Castellano 2026-05-09 14:16:48 -03:00
parent b322a7074f
commit 28e368796a

View file

@ -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(() => {