/**
* ChannelWelcomeSection — the "start of channel" header rendered above
* the first message in any channel view. Two variants:
*
* - DM (1:1) → centred avatar + display name + "@username" handle +
* "This is the beginning of your direct message history with Name."
* - Text channel → "Welcome to #channel-name!" with the Hash icon
* and a short description.
*
* Voice channels never reach the message list so they never need this.
*/
import { useMemo } from 'react';
import { useQuery } from 'convex/react';
import { Hash } from '@phosphor-icons/react';
import { Avatar } from '@discord-clone/ui';
import { api } from '../../../../../convex/_generated/api';
import { useOnlineUsers } from '../../contexts/PresenceContext';
import styles from './ChannelWelcomeSection.module.css';
interface ChannelWelcomeSectionProps {
channelId: string;
channelName?: string;
channelType?: string;
}
function mapPresence(
status: string | undefined,
): 'online' | 'idle' | 'dnd' | 'offline' {
switch (status) {
case 'online':
return 'online';
case 'idle':
return 'idle';
case 'dnd':
return 'dnd';
default:
return 'offline';
}
}
export function ChannelWelcomeSection({
channelId,
channelName,
channelType,
}: ChannelWelcomeSectionProps) {
if (channelType === 'dm') {
return
This is the start of the #{name} channel. All messages are end-to-end encrypted.
This is the beginning of your direct message history with{' '} {displayName}.