This commit is contained in:
2025-12-08 12:19:53 +00:00
parent 9eeb88e9ea
commit 81674f8094
5 changed files with 324 additions and 86 deletions
+6
View File
@@ -5,6 +5,7 @@ import { Button } from '@/components/ui/button';
import { Textarea } from '@/components/ui/textarea';
import { ScrollArea } from '@/components/ui/scroll-area';
import { useSettings } from '@/contexts/SettingsContext';
import { useAchievements, incrementAiMessageCount } from '@/contexts/AchievementsContext';
import { useToast } from '@/hooks/use-toast';
import GlitchText from '@/components/GlitchText';
import MessageContent from '@/components/MessageContent';
@@ -79,6 +80,7 @@ const AIChat = () => {
const [tempCustomConfig, setTempCustomConfig] = useState<CustomApiConfig>({ endpoint: '', apiKey: '', model: '' });
const scrollRef = useRef<HTMLDivElement>(null);
const { playSound } = useSettings();
const { checkAiAchievements } = useAchievements();
const { toast } = useToast();
// Persist messages to localStorage
@@ -134,6 +136,10 @@ const AIChat = () => {
setInput('');
setIsLoading(true);
playSound('click');
// Track AI message count for achievements
incrementAiMessageCount();
checkAiAchievements();
try {
// Build chat history, filtering out empty messages, system notices, and ensuring proper alternation
+44 -7
View File
@@ -33,7 +33,8 @@ const Index = () => {
});
const [showConsentModal, setShowConsentModal] = useState(false);
const [konamiActive, setKonamiActive] = useState(false);
const { crtEnabled, playSound } = useSettings();
const [audioPromptDismissed, setAudioPromptDismissed] = useState(false);
const { crtEnabled, playSound, cryptoConsent, audioBlocked, resetAudioContext, setSoundEnabled } = useSettings();
const { unlockAchievement } = useAchievements();
const { activated: konamiActivated, reset: resetKonami } = useKonamiCode();
const location = useLocation();
@@ -77,15 +78,47 @@ const Index = () => {
useEffect(() => {
const timer = setTimeout(() => {
setIsLoading(false);
// Show consent modal after loading if user hasn't made a choice yet
const hasSeenConsent = localStorage.getItem('cryptoConsentSeen');
if (!hasSeenConsent) {
// Show consent modal after loading if user hasn't accepted yet (null = needs prompt)
if (cryptoConsent === null) {
setShowConsentModal(true);
}
}, 3000); // Extended to 3s for boot sequence
return () => clearTimeout(timer);
}, []);
}, [cryptoConsent]);
// Show audio blocked prompt
useEffect(() => {
if (audioBlocked && !audioPromptDismissed) {
toast({
title: "Sound Effects Blocked",
description: "Click anywhere or disable sounds in settings",
action: (
<div className="flex gap-2">
<button
onClick={() => {
resetAudioContext();
setAudioPromptDismissed(true);
}}
className="px-2 py-1 text-xs border border-primary rounded hover:bg-primary/20"
>
Retry
</button>
<button
onClick={() => {
setSoundEnabled(false);
setAudioPromptDismissed(true);
}}
className="px-2 py-1 text-xs border border-primary rounded hover:bg-primary/20"
>
Disable
</button>
</div>
),
duration: 10000,
});
}
}, [audioBlocked, audioPromptDismissed, resetAudioContext, setSoundEnabled]);
useEffect(() => {
if (isRedTheme) {
@@ -104,17 +137,21 @@ const Index = () => {
};
const handleConsentClose = () => {
localStorage.setItem('cryptoConsentSeen', 'true');
setShowConsentModal(false);
};
const handleVerified = () => {
setIsVerified(true);
unlockAchievement('verified_human');
};
// Show verification gate if not verified
if (!isVerified) {
return (
<div className={`min-h-screen overflow-x-hidden ${crtEnabled ? 'crt' : ''}`}>
<MatrixRain color={isRedTheme ? '#FF0000' : '#00FF00'} />
<Suspense fallback={null}>
<HumanVerification onVerified={() => setIsVerified(true)} />
<HumanVerification onVerified={handleVerified} />
</Suspense>
</div>
);