import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger, } from '@/components/ui/dropdown-menu'; import { IconButton } from '@/components/ui/button'; import { Separator } from '@/components/ui/separator'; import { AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogTitle, } from '@/components/ui/alert-dialog'; import { useRouter } from 'next/navigation'; import { useState } from 'react'; import { useStreamChatStore } from '@/stores/stream-chat'; import { useAsyncFn } from '@/hooks/tools'; interface ChatSidebarActionProps { onSearchClick?: () => void; onCancelSearch?: () => void; isSearchActive?: boolean; } const ChatSidebarAction = ({ onSearchClick, onCancelSearch, isSearchActive = false, }: ChatSidebarActionProps) => { const clearNotifications = useStreamChatStore((state) => state.clearNotifications); const clearChannels = useStreamChatStore((state) => state.clearChannels); const [isDeleteMessageDialogOpen, setIsDeleteMessageDialogOpen] = useState(false); const router = useRouter(); const { run: handleClearChannels, loading } = useAsyncFn(async () => { await clearChannels(); setIsDeleteMessageDialogOpen(false); router.replace('/'); }); return ( <> Mark All {isSearchActive ? 'Cancel' : 'Search'}
setIsDeleteMessageDialogOpen(true)}> Clear Chat List
{/* 删除全部 确认modal */} Clear Chat List This will clear your chat list. Your individual messages will remain intact. Cancel Clear ); }; export default ChatSidebarAction;