From 764cb428941710a8c88d1d2e8ec9460ae7cadc74 Mon Sep 17 00:00:00 2001 From: Jakub Zych Date: Sun, 1 Nov 2026 19:17:42 +0100 Subject: [PATCH] refactor: the DM-only conversation-actions rule as a helper dmActionsTarget (app/lib/slots.ts) answers the open DM's row or null; ChatHeader renders the slot from it. Same behaviour, testable outside a component. --- app/components/Chat/Header.vue | 7 ++++--- app/lib/slots.ts | 11 +++++++++++ 2 files changed, 15 insertions(+), 3 deletions(-) create mode 100644 app/lib/slots.ts diff --git a/app/components/Chat/Header.vue b/app/components/Chat/Header.vue index b8958e9..6c9c922 100644 --- a/app/components/Chat/Header.vue +++ b/app/components/Chat/Header.vue @@ -10,6 +10,7 @@ // only when the open conversation is a DM. import { badgeText } from '../../lib/chatUnread' import { shortName } from '../../lib/chatFormat' +import { dmActionsTarget } from '../../lib/slots' const props = withDefaults(defineProps<{ back?: boolean; pinsOpen?: boolean }>(), { back: true, pinsOpen: false }) const emit = defineEmits<{ back: []; pins: [] }>() @@ -18,8 +19,8 @@ const chat = useChat() const channel = computed(() => chat.activeChannel) const dm = computed(() => chat.activeDm) -/** The open conversation's kind and row, for the DM-only slot. */ -const conversation = computed(() => dm.value ?? null) +/** The open DM's row, for the DM-only slot (null in a channel). */ +const conversation = computed(() => dmActionsTarget(dm.value)) const dmName = computed(() => (dm.value ? shortName(chat.members.get(dm.value.other_user_id), '', t('chat.someone')) : '')) const title = computed(() => (channel.value ? `# ${channel.value.name}` : dmName.value)) const eyebrow = computed(() => (channel.value ? t('chat.header.channel') : t('chat.header.dm'))) @@ -90,7 +91,7 @@ async function leave() {
- +