()
| 23 | import toggleFullscreen from '@/utils/toggle-fullscreen'; |
| 24 | |
| 25 | export function Sidebar() { |
| 26 | const [darkMode, setDarkMode] = useState(false); |
| 27 | const [isCollapsed, setIsCollapsed] = useState(true); |
| 28 | const [showNotifications, setShowNotifications] = useState(false); |
| 29 | const [showLanguageSelector, setShowLanguageSelector] = useState(false); |
| 30 | const [gamepadConnected, setGamepadConnected] = useState(false); |
| 31 | const { joystickEnabled, setJoystickEnabled } = useHeader(); |
| 32 | const { state: notificationsState } = useNotifications(); |
| 33 | const { themeColor, setThemeColor } = useTheme(); |
| 34 | const { language, setLanguage, t } = useLanguage(); |
| 35 | |
| 36 | // Initialize demo notifications |
| 37 | useDemoNotifications(); |
| 38 | |
| 39 | // Initialize dark mode from DOM |
| 40 | useEffect(() => { |
| 41 | const isDark = document.documentElement.classList.contains('dark'); |
| 42 | setDarkMode(isDark); |
| 43 | }, []); |
| 44 | |
| 45 | // Check for gamepad connectivity |
| 46 | useEffect(() => { |
| 47 | const checkGamepads = () => { |
| 48 | const gamepads = navigator.getGamepads(); |
| 49 | setGamepadConnected(gamepads.some((gamepad) => gamepad !== null)); |
| 50 | }; |
| 51 | |
| 52 | // Initial check |
| 53 | checkGamepads(); |
| 54 | |
| 55 | // Event listeners for gamepad connections/disconnections |
| 56 | const handleGamepadConnected = () => { |
| 57 | setGamepadConnected(true); |
| 58 | }; |
| 59 | |
| 60 | const handleGamepadDisconnected = () => { |
| 61 | // We need to check if any gamepads are still connected |
| 62 | setTimeout(checkGamepads, 100); |
| 63 | }; |
| 64 | |
| 65 | window.addEventListener('gamepadconnected', handleGamepadConnected); |
| 66 | window.addEventListener('gamepaddisconnected', handleGamepadDisconnected); |
| 67 | |
| 68 | // Regular check for gamepad status |
| 69 | const interval = setInterval(checkGamepads, 1000); |
| 70 | |
| 71 | return () => { |
| 72 | window.removeEventListener('gamepadconnected', handleGamepadConnected); |
| 73 | window.removeEventListener( |
| 74 | 'gamepaddisconnected', |
| 75 | handleGamepadDisconnected |
| 76 | ); |
| 77 | clearInterval(interval); |
| 78 | }; |
| 79 | }, []); |
| 80 | |
| 81 | const unreadCount = notificationsState.notifications.filter( |
| 82 | (n) => !n.read |
nothing calls this directly
no test coverage detected