From df81532c67e02b1daa47efbb69e64db9ec76ff4b Mon Sep 17 00:00:00 2001 From: Paulo Castellano Date: Tue, 16 Jun 2026 16:14:59 -0300 Subject: [PATCH] feat(channels): show channel + mentions in Discord preview, light theme Persist channel_name (display-only) so the preview header shows the chosen channel; render mentions as pills; restyle the preview to a light theme to match the rest of the app. --- .../Requests/App/Post/UpdatePostRequest.php | 1 + .../posts/editor/DiscordSettings.vue | 10 ++++++ .../posts/previews/DiscordPreview.vue | 36 ++++++++++++++----- 3 files changed, 38 insertions(+), 9 deletions(-) diff --git a/app/Http/Requests/App/Post/UpdatePostRequest.php b/app/Http/Requests/App/Post/UpdatePostRequest.php index 1f70fcd8..9e6d9c74 100644 --- a/app/Http/Requests/App/Post/UpdatePostRequest.php +++ b/app/Http/Requests/App/Post/UpdatePostRequest.php @@ -83,6 +83,7 @@ public function rules(): array 'platforms.*.meta.brand_organic_toggle' => ['sometimes', 'boolean'], 'platforms.*.meta.board_id' => ['sometimes', 'nullable', 'string'], 'platforms.*.meta.channel_id' => ['sometimes', 'nullable', 'string'], + 'platforms.*.meta.channel_name' => ['sometimes', 'nullable', 'string'], 'platforms.*.meta.mentions' => ['sometimes', 'nullable', 'array'], 'platforms.*.meta.mentions.*.token' => ['required', 'string'], 'platforms.*.meta.mentions.*.label' => ['sometimes', 'nullable', 'string'], diff --git a/resources/js/components/posts/editor/DiscordSettings.vue b/resources/js/components/posts/editor/DiscordSettings.vue index c141ea97..2393db83 100644 --- a/resources/js/components/posts/editor/DiscordSettings.vue +++ b/resources/js/components/posts/editor/DiscordSettings.vue @@ -100,6 +100,16 @@ const channelOptions = computed(() => { const channelSelectOptions = computed(() => channelOptions.value.map((channel) => ({ value: channel.id, label: `#${channel.name}` }))); +// Persist the channel NAME alongside the id (display-only, for the preview) and +// keep it fresh as the live list loads or the channel is renamed. +watch([channelId, channels], () => { + const name = channels.value.find((channel) => channel.id === channelId.value)?.name; + + if (name && props.meta?.channel_name !== name) { + updateMeta({ channel_name: name }); + } +}, { immediate: true }); + const errors = usePageErrors(); const channelError = computed(() => { if (props.meta?.channel_id) { diff --git a/resources/js/components/posts/previews/DiscordPreview.vue b/resources/js/components/posts/previews/DiscordPreview.vue index f9621ac4..cacd47b2 100644 --- a/resources/js/components/posts/previews/DiscordPreview.vue +++ b/resources/js/components/posts/previews/DiscordPreview.vue @@ -21,6 +21,11 @@ interface EmbedDraft { color?: string; } +interface MentionChip { + token: string; + label: string; +} + const props = defineProps<{ socialAccount: SocialAccount; content: string; @@ -29,14 +34,16 @@ const props = defineProps<{ }>(); const embeds = computed(() => (Array.isArray(props.meta?.embeds) ? (props.meta!.embeds as EmbedDraft[]) : [])); +const channelName = computed(() => (props.meta?.channel_name as string) || 'channel'); +const mentions = computed(() => (Array.isArray(props.meta?.mentions) ? (props.meta!.mentions as MentionChip[]) : []));