Changes
This commit is contained in:
+4
-12
@@ -8,7 +8,6 @@ import { useSettings } from '@/contexts/SettingsContext';
|
|||||||
import { useAchievements, incrementAiMessageCount } from '@/contexts/AchievementsContext';
|
import { useAchievements, incrementAiMessageCount } from '@/contexts/AchievementsContext';
|
||||||
import { useToast } from '@/hooks/use-toast';
|
import { useToast } from '@/hooks/use-toast';
|
||||||
import GlitchText from '@/components/GlitchText';
|
import GlitchText from '@/components/GlitchText';
|
||||||
import { useBrowserFullscreen } from '@/hooks/useGameDimensions';
|
|
||||||
import MessageContent from '@/components/MessageContent';
|
import MessageContent from '@/components/MessageContent';
|
||||||
import { AI_PROVIDERS, AIProvider, getProvider, CUSTOM_API_STORAGE_KEY } from '@/lib/aiProviders';
|
import { AI_PROVIDERS, AIProvider, getProvider, CUSTOM_API_STORAGE_KEY } from '@/lib/aiProviders';
|
||||||
import {
|
import {
|
||||||
@@ -83,7 +82,6 @@ const AIChat = () => {
|
|||||||
const { playSound } = useSettings();
|
const { playSound } = useSettings();
|
||||||
const { checkAiAchievements } = useAchievements();
|
const { checkAiAchievements } = useAchievements();
|
||||||
const { toast } = useToast();
|
const { toast } = useToast();
|
||||||
const { enterFullscreen, exitFullscreen } = useBrowserFullscreen();
|
|
||||||
|
|
||||||
// Persist messages to localStorage
|
// Persist messages to localStorage
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@@ -106,27 +104,21 @@ const AIChat = () => {
|
|||||||
}
|
}
|
||||||
}, [customApiConfig]);
|
}, [customApiConfig]);
|
||||||
|
|
||||||
|
// Exit fullscreen on Escape key
|
||||||
// Exit fullscreen on Escape key
|
// Exit fullscreen on Escape key
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const handleEscape = (e: KeyboardEvent) => {
|
const handleEscape = (e: KeyboardEvent) => {
|
||||||
if (e.key === 'Escape' && isFullscreen) {
|
if (e.key === 'Escape' && isFullscreen) {
|
||||||
setIsFullscreen(false);
|
setIsFullscreen(false);
|
||||||
exitFullscreen();
|
|
||||||
playSound('click');
|
playSound('click');
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
window.addEventListener('keydown', handleEscape);
|
window.addEventListener('keydown', handleEscape);
|
||||||
return () => window.removeEventListener('keydown', handleEscape);
|
return () => window.removeEventListener('keydown', handleEscape);
|
||||||
}, [isFullscreen, playSound, exitFullscreen]);
|
}, [isFullscreen, playSound]);
|
||||||
|
|
||||||
const toggleFullscreen = async () => {
|
const toggleFullscreen = () => {
|
||||||
if (!isFullscreen) {
|
setIsFullscreen(prev => !prev);
|
||||||
setIsFullscreen(true);
|
|
||||||
await enterFullscreen();
|
|
||||||
} else {
|
|
||||||
setIsFullscreen(false);
|
|
||||||
await exitFullscreen();
|
|
||||||
}
|
|
||||||
playSound('click');
|
playSound('click');
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user