Changes
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
import { useState, useRef, useEffect } from 'react';
|
import { useState, useRef, useEffect } from 'react';
|
||||||
import { useNavigate } from 'react-router-dom';
|
import { useNavigate, useLocation } from 'react-router-dom';
|
||||||
import { motion, AnimatePresence } from 'framer-motion';
|
import { motion, AnimatePresence } from 'framer-motion';
|
||||||
import { Terminal, X } from 'lucide-react';
|
import { Terminal, X } from 'lucide-react';
|
||||||
import { useSettings } from '@/contexts/SettingsContext';
|
import { useSettings } from '@/contexts/SettingsContext';
|
||||||
@@ -70,9 +70,13 @@ const TerminalCommand = () => {
|
|||||||
const inputRef = useRef<HTMLInputElement>(null);
|
const inputRef = useRef<HTMLInputElement>(null);
|
||||||
const outputRef = useRef<HTMLDivElement>(null);
|
const outputRef = useRef<HTMLDivElement>(null);
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
|
const location = useLocation();
|
||||||
const { playSound } = useSettings();
|
const { playSound } = useSettings();
|
||||||
const { unlockAchievement } = useAchievements();
|
const { unlockAchievement } = useAchievements();
|
||||||
|
|
||||||
|
// Check if user is on a game page
|
||||||
|
const isOnGamePage = location.pathname.startsWith('/games/');
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (isOpen && inputRef.current) {
|
if (isOpen && inputRef.current) {
|
||||||
inputRef.current.focus();
|
inputRef.current.focus();
|
||||||
@@ -98,8 +102,8 @@ const TerminalCommand = () => {
|
|||||||
playSound('beep');
|
playSound('beep');
|
||||||
}
|
}
|
||||||
|
|
||||||
// Open terminal when pressing "/" (only if not in input)
|
// Open terminal when pressing "/" (only if not in input and not on a game page)
|
||||||
if (e.key === '/' && !isOpen && !isInputFocused) {
|
if (e.key === '/' && !isOpen && !isInputFocused && !isOnGamePage) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
setIsOpen(true);
|
setIsOpen(true);
|
||||||
playSound('beep');
|
playSound('beep');
|
||||||
@@ -114,7 +118,7 @@ const TerminalCommand = () => {
|
|||||||
|
|
||||||
window.addEventListener('keydown', handleKeyDown);
|
window.addEventListener('keydown', handleKeyDown);
|
||||||
return () => window.removeEventListener('keydown', handleKeyDown);
|
return () => window.removeEventListener('keydown', handleKeyDown);
|
||||||
}, [isOpen, playSound]);
|
}, [isOpen, playSound, isOnGamePage]);
|
||||||
|
|
||||||
const handleSubmit = (e: React.FormEvent) => {
|
const handleSubmit = (e: React.FormEvent) => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
|||||||
Reference in New Issue
Block a user