From a6bfcb10b0294ac6b90236abf962637c12fd60eb Mon Sep 17 00:00:00 2001 From: 230419 <230419@epvc.pt> Date: Tue, 9 Jun 2026 01:10:51 +0100 Subject: [PATCH] savesave --- src/App.jsx | 21 ++++++++++++++++++--- src/lib/i18n.js | 5 +++++ 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/src/App.jsx b/src/App.jsx index d037daf..c29d4ef 100644 --- a/src/App.jsx +++ b/src/App.jsx @@ -73,6 +73,7 @@ export default function App() { const [shortcutUpKey, setShortcutUpKey] = useState('q'); const [shortcutDownKey, setShortcutDownKey] = useState('e'); const [recordingKey, setRecordingKey] = useState(null); + const [shortcutConflict, setShortcutConflict] = useState(false); const [userStatus, setUserStatus] = useState('online'); // Estado da Comunidade @@ -308,6 +309,8 @@ export default function App() { useEffect(() => { if (!shortcutsEnabled) return; + // Se as teclas forem iguais, ambos os atalhos ficam desativados + if (shortcutUpKey.toLowerCase() === shortcutDownKey.toLowerCase()) return; const handleKeyDown = (e) => { if (e.target.tagName === 'INPUT' || e.target.tagName === 'TEXTAREA') return; @@ -338,16 +341,18 @@ export default function App() { if (recordingKey === 'up') { setShortcutUpKey(key); saveUserSetting('shortcutUpKey', key); + setShortcutConflict(key.toLowerCase() === shortcutDownKey.toLowerCase()); } else if (recordingKey === 'down') { setShortcutDownKey(key); saveUserSetting('shortcutDownKey', key); + setShortcutConflict(key.toLowerCase() === shortcutUpKey.toLowerCase()); } setRecordingKey(null); }; window.addEventListener('keydown', handleCapture, true); return () => window.removeEventListener('keydown', handleCapture, true); - }, [recordingKey]); + }, [recordingKey, shortcutUpKey, shortcutDownKey]); useEffect(() => { if (editingItem && editingItem.color) { @@ -493,8 +498,11 @@ export default function App() { } if (data.settings.isPrivate !== undefined) setIsPrivate(data.settings.isPrivate); if (data.settings.shortcutsEnabled !== undefined) setShortcutsEnabled(data.settings.shortcutsEnabled); - if (data.settings.shortcutUpKey !== undefined) setShortcutUpKey(data.settings.shortcutUpKey); - if (data.settings.shortcutDownKey !== undefined) setShortcutDownKey(data.settings.shortcutDownKey); + const loadedUp = data.settings.shortcutUpKey !== undefined ? data.settings.shortcutUpKey : 'q'; + const loadedDown = data.settings.shortcutDownKey !== undefined ? data.settings.shortcutDownKey : 'e'; + if (data.settings.shortcutUpKey !== undefined) setShortcutUpKey(loadedUp); + if (data.settings.shortcutDownKey !== undefined) setShortcutDownKey(loadedDown); + setShortcutConflict(loadedUp.toLowerCase() === loadedDown.toLowerCase()); if (data.settings.status !== undefined) setUserStatus(data.settings.status); } } @@ -2814,6 +2822,13 @@ export default function App() { )} + {shortcutsEnabled && shortcutConflict && ( +
{t('dailyOutfitNotification')}
diff --git a/src/lib/i18n.js b/src/lib/i18n.js index 0e1a8ce..50bf645 100644 --- a/src/lib/i18n.js +++ b/src/lib/i18n.js @@ -231,6 +231,7 @@ export const translations = { shortcutDownDesc: "Tecla para navegar para baixo no menu", pressAnyKey: "Pressione uma tecla...", spaceKey: "Espaço", + shortcutConflictWarning: "Não podes usar a mesma tecla para cima e para baixo. Os atalhos estão desativados.", }, EN: { loginModeIntro: "The Future of Your Style", @@ -464,6 +465,7 @@ export const translations = { shortcutDownDesc: "Key to navigate down in the menu", pressAnyKey: "Press a key...", spaceKey: "Space", + shortcutConflictWarning: "You cannot use the same key for up and down. Shortcuts are disabled.", }, ES: { loginModeIntro: "El Futuro de Tu Estilo", @@ -697,6 +699,7 @@ export const translations = { shortcutDownDesc: "Tecla para navegar hacia abajo en el menú", pressAnyKey: "Presione una tecla...", spaceKey: "Espacio", + shortcutConflictWarning: "No puedes usar la misma tecla para arriba y abajo. Los atajos están desactivados.", }, FR: { loginModeIntro: "Le Futur de Ton Style", @@ -930,6 +933,7 @@ export const translations = { shortcutDownDesc: "Touche pour naviguer vers le bas dans le menu", pressAnyKey: "Appuyez sur une touche...", spaceKey: "Espace", + shortcutConflictWarning: "Vous ne pouvez pas utiliser la même touche pour haut et bas. Les raccourcis sont désactivés.", }, DE: { loginModeIntro: "Die Zukunft deines Stils", @@ -1163,5 +1167,6 @@ export const translations = { shortcutDownDesc: "Taste zum Navigieren nach unten im Menü", pressAnyKey: "Taste drücken...", spaceKey: "Leertaste", + shortcutConflictWarning: "Du kannst dieselbe Taste nicht für oben und unten verwenden. Tastenkürzel sind deaktiviert.", } };