| import { useEffect, useRef } from 'react'; |
| import { useResetRecoilState } from 'recoil'; |
| import { logger } from '~/utils'; |
| import store from '~/store'; |
|
|
| |
| |
| |
| |
| export default function useIdChangeEffect(conversationId: string) { |
| const lastConvoId = useRef<string | null>(null); |
| const resetVisibleArtifacts = useResetRecoilState(store.visibleArtifacts); |
|
|
| useEffect(() => { |
| if (conversationId !== lastConvoId.current) { |
| logger.log('conversation', 'Conversation ID change'); |
| resetVisibleArtifacts(); |
| } |
| lastConvoId.current = conversationId; |
| }, [conversationId, resetVisibleArtifacts]); |
| } |
|
|