2024-05-14 11:00:01 -04:00
|
|
|
import { Link } from 'lucide-react';
|
|
|
|
|
import type { TMessage } from 'librechat-data-provider';
|
|
|
|
|
import { useLocalize, useNavigateToConvo } from '~/hooks';
|
|
|
|
|
import { useSearchContext } from '~/Providers';
|
|
|
|
|
import { getConversationById } from '~/utils';
|
|
|
|
|
|
|
|
|
|
export default function SearchButtons({ message }: { message: TMessage }) {
|
|
|
|
|
const localize = useLocalize();
|
|
|
|
|
const { searchQueryRes } = useSearchContext();
|
|
|
|
|
const { navigateWithLastTools } = useNavigateToConvo();
|
2025-01-12 12:57:10 -05:00
|
|
|
const conversationId = message.conversationId ?? '';
|
2024-05-14 11:00:01 -04:00
|
|
|
|
2025-01-12 12:57:10 -05:00
|
|
|
if (!conversationId) {
|
2024-05-14 11:00:01 -04:00
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
2025-01-12 12:57:10 -05:00
|
|
|
const clickHandler = (event: React.MouseEvent<HTMLButtonElement>) => {
|
2024-05-14 11:00:01 -04:00
|
|
|
event.preventDefault();
|
|
|
|
|
|
2025-01-12 12:57:10 -05:00
|
|
|
const conversation = getConversationById(searchQueryRes?.data, conversationId);
|
2024-05-14 11:00:01 -04:00
|
|
|
if (!conversation) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
document.title = message.title ?? '';
|
2025-01-12 12:57:10 -05:00
|
|
|
navigateWithLastTools(conversation, true, true);
|
2024-05-14 11:00:01 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
return (
|
2025-01-12 12:57:10 -05:00
|
|
|
<div className="visible mt-0 flex items-center justify-center gap-1 self-end text-text-secondary lg:justify-start">
|
|
|
|
|
<button
|
|
|
|
|
className="ml-0 flex cursor-pointer items-center gap-1.5 rounded-md p-1 text-xs hover:text-text-primary hover:underline"
|
2024-05-14 11:00:01 -04:00
|
|
|
onClick={clickHandler}
|
|
|
|
|
title={localize('com_ui_go_to_conversation')}
|
|
|
|
|
>
|
|
|
|
|
<Link className="icon-sm" />
|
|
|
|
|
{message.title}
|
2025-01-12 12:57:10 -05:00
|
|
|
</button>
|
2024-05-14 11:00:01 -04:00
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
}
|