Skip to content

🤯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.

892 B
Raw Blame
'use client';

import { type FC, memo } from 'react';
import { useParams } from 'react-router';

import { useClearActiveTopicUnread } from '@/features/Conversation/hooks';
import { useTopicCommentDeepLink } from '@/features/TopicComment/useTopicCommentDeepLink';

import { useChatRouteSync } from './useChatRouteSync';

// sync outside state to useChatStore
interface ChatHydrationProps {
  getConversationPath?: (agentId: string) => string;
  getTopicPath?: (agentId: string, topicId: string) => string;
}

const ChatHydration: FC<ChatHydrationProps> = memo(({ getConversationPath, getTopicPath }) => {
  const params = useParams<{ aid?: string; topicId?: string }>();
  const routeTopicId = params.topicId;

  useClearActiveTopicUnread();
  useTopicCommentDeepLink(routeTopicId);
  useChatRouteSync({ getConversationPath, getTopicPath });

  return null;
});

export default ChatHydration;