/** * Copyright (c) 2023-present Plane Software, Inc. and contributors * SPDX-License-Identifier: AGPL-3.0-only * See the LICENSE file for details. */ // components import { observer } from "mobx-react"; import { useParams, usePathname } from "next/navigation"; import { cn } from "@plane/utils"; import { DeferredTopNavPowerK } from "@/components/navigation/deferred-top-nav-power-k"; import { UserMenuRoot } from "@/components/workspace/sidebar/user-menu-root"; import { WorkspaceMenuRoot } from "@/components/workspace/sidebar/workspace-menu-root"; import { useAppRailPreferences } from "@/hooks/use-navigation-preferences"; import { usePlatformOS } from "@/hooks/use-platform-os"; import { Tooltip } from "@plane/propel/tooltip"; import { AppSidebarItem } from "@/components/sidebar/sidebar-item"; import { InboxIcon } from "@plane/propel/icons"; import useSWR from "swr"; import { useWorkspaceNotifications } from "@/hooks/store/notifications"; export const TopNavigationRoot = observer(function TopNavigationRoot() { // router const { workspaceSlug } = useParams(); const pathname = usePathname(); // store hooks const { unreadNotificationsCount, getUnreadNotificationsCount } = useWorkspaceNotifications(); const { preferences } = useAppRailPreferences(); const { isMobile } = usePlatformOS(); const showLabel = preferences.displayMode === "icon_with_label"; // Fetch notification count useSWR( workspaceSlug ? "WORKSPACE_UNREAD_NOTIFICATION_COUNT" : null, workspaceSlug ? () => getUnreadNotificationsCount(workspaceSlug.toString()) : null ); // Calculate notification count const isMentionsEnabled = unreadNotificationsCount.mention_unread_notifications_count > 0; const totalNotifications = isMentionsEnabled ? unreadNotificationsCount.mention_unread_notifications_count : unreadNotificationsCount.total_unread_notifications_count; if (!isMobile) return null; return (