/**
* @file components/sidebar/ChannelSidebar.tsx
* @description Sidebar component listing channels for the active server, or rendering direct messages when no server is active.
*/
"use client";
import Link from "next/link";
import { useParams } from "next/navigation";
import { useActiveServer } from "@/lib/context/ServerContext";
import { DirectMessageSidebar } from "@/components/sidebar/DirectMessageSidebar";
import { useSidebarStore } from "@/lib/stores/useSidebarStore";
import { PanelLeftClose } from "lucide-react";
/**
* Renders the channel sidebar for the active server or defaults to the direct message view.
* Handles responsive sidebar toggling and highlights active channels based on URL parameters.
*
* @returns {JSX.Element} The rendered channel sidebar or direct message sidebar component.
*/
export function ChannelSidebar() {
const params = useParams();
const currentChannelId = params?.channelId as string;
const { activeServer } = useActiveServer();
const { closeNav, toggleNav } = useSidebarStore();
/**
* Closes the mobile navigation drawer when a channel link is selected on viewports smaller than 768px.
*/
const handleChannelClick = () => {
if (!window.matchMedia("(min-width: 768px)").matches) {
closeNav();
}
};
if (!activeServer) {
return