Update ChatNotifications.tsx

This commit is contained in:
NotII
2025-03-07 02:04:03 +00:00
parent 7b8e034ae4
commit e3a4c4f564

View File

@@ -160,31 +160,32 @@ export default function ChatNotifications() {
router.push(`/dashboard/chats/${chatId}`); router.push(`/dashboard/chats/${chatId}`);
}; };
if (loading || unreadCounts.totalUnread === 0) {
return (
<Button variant="ghost" size="icon" className="relative" disabled={loading}>
<Bell className="h-5 w-5" />
</Button>
);
}
return ( return (
<DropdownMenu> <DropdownMenu>
<DropdownMenuTrigger asChild> <DropdownMenuTrigger asChild>
<Button variant="ghost" size="icon" className="relative"> <Button variant="ghost" size="icon" className="relative" disabled={loading}>
<Bell className="h-5 w-5" /> <Bell className="h-5 w-5" />
{unreadCounts.totalUnread > 0 && (
<Badge <Badge
variant="destructive" variant="destructive"
className="absolute -top-1 -right-1 px-1.5 py-0.5 text-xs" className="absolute -top-1 -right-1 px-1.5 py-0.5 text-xs"
> >
{unreadCounts.totalUnread} {unreadCounts.totalUnread}
</Badge> </Badge>
)}
</Button> </Button>
</DropdownMenuTrigger> </DropdownMenuTrigger>
<DropdownMenuContent align="end" className="w-72"> <DropdownMenuContent align="end" className="w-72">
<div className="p-2 border-b"> <div className="p-2 border-b">
<h3 className="font-medium">Unread Messages</h3> <h3 className="font-medium">Messages</h3>
</div> </div>
{unreadCounts.totalUnread === 0 ? (
<div className="p-4 flex items-center justify-center">
<p className="text-sm text-muted-foreground">No new notifications</p>
</div>
) : (
<>
<div className="max-h-80 overflow-y-auto"> <div className="max-h-80 overflow-y-auto">
{Object.entries(unreadCounts.chatCounts).map(([chatId, count]) => ( {Object.entries(unreadCounts.chatCounts).map(([chatId, count]) => (
<DropdownMenuItem <DropdownMenuItem
@@ -215,6 +216,8 @@ export default function ChatNotifications() {
View All Chats View All Chats
</Button> </Button>
</div> </div>
</>
)}
</DropdownMenuContent> </DropdownMenuContent>
</DropdownMenu> </DropdownMenu>
); );