Files
overleaf-cep/services/web/frontend/js/features/pdf-preview/components/error-assistant-ai-paywall-notification.tsx
Mathias Jakobsen 76fbb56107 [web] Delay suggest fix paywall until suggest button has been clicked (#33458)
GitOrigin-RevId: 11d2ec0c9c33aea3fedff57d5f1a74d6ce774017
2026-05-07 08:08:36 +00:00

31 lines
894 B
TypeScript

import { useCallback, useEffect, useState } from 'react'
import AiPaywallNotification from '@/shared/components/ai-paywall-notification'
import { useDetachCompileContext as useCompileContext } from '@/shared/context/detach-compile-context'
import useEventListener from '@/shared/hooks/use-event-listener'
export default function ErrorAssistantAiPaywallNotification() {
const { showLogs } = useCompileContext()
const [hasTriggered, setHasTriggered] = useState(false)
useEventListener(
'aiAssist:showPaywall',
useCallback((event: CustomEvent<{ origin?: string }>) => {
if (event.detail?.origin === 'suggest-fix') {
setHasTriggered(true)
}
}, [])
)
useEffect(() => {
if (!showLogs) {
setHasTriggered(false)
}
}, [showLogs])
if (!hasTriggered) {
return null
}
return <AiPaywallNotification featureLocation="errorAssist" />
}