import { useState, type FC } from 'react'; import { useRecoilValue } from 'recoil'; import { useLocation } from 'react-router-dom'; import { TConversation } from 'librechat-data-provider'; import { Content, Portal, Root, Trigger } from '@radix-ui/react-popover'; import { BookmarkFilledIcon, BookmarkIcon } from '@radix-ui/react-icons'; import { useGetConversationTags } from 'librechat-data-provider/react-query'; import { BookmarkContext } from '~/Providers/BookmarkContext'; import BookmarkNavItems from './BookmarkNavItems'; import { useLocalize } from '~/hooks'; import { cn } from '~/utils'; import store from '~/store'; type BookmarkNavProps = { tags: string[]; setTags: (tags: string[]) => void; }; const BookmarkNav: FC = ({ tags, setTags }: BookmarkNavProps) => { const localize = useLocalize(); const location = useLocation(); const { data } = useGetConversationTags(); const activeConvo = useRecoilValue(store.conversationByIndex(0)); const globalConvo = useRecoilValue(store.conversation) ?? ({} as TConversation); const [open, setIsOpen] = useState(false); let conversation: TConversation | null | undefined; if (location.state?.from?.pathname.includes('/chat')) { conversation = globalConvo; } else { conversation = activeConvo; } // Hide the button if there are no tags if (!data || !data.some((tag) => tag.count > 0)) { return null; } return (
{data && conversation && data.some((tag) => tag.count > 0) && ( // Display bookmarks and highlight the selected tag tag.count > 0) }}> )}
); }; export default BookmarkNav;