diff --git a/www/src/Pages/SettingsPage.jsx b/www/src/Pages/SettingsPage.jsx index ee15bc565..1a9a4cd0d 100644 --- a/www/src/Pages/SettingsPage.jsx +++ b/www/src/Pages/SettingsPage.jsx @@ -99,7 +99,7 @@ const SHA256 = (ascii) => { (rightRotate(w15, 7) ^ rightRotate(w15, 18) ^ (w15 >>> 3)) + // s0 w[i - 7] + (rightRotate(w2, 17) ^ rightRotate(w2, 19) ^ (w2 >>> 10))) | // s1 - 0); + 0); // This is only used once, so *could* be moved below, but it only saves 4 bytes and makes things unreadble const temp2 = (rightRotate(a, 2) ^ rightRotate(a, 13) ^ rightRotate(a, 22)) + // S0 @@ -324,7 +324,28 @@ const hotkeyFields = Array(16) const newSchema = yup .object() .label('Hotkey ' + number) - .shape({ ...hotkeySchema }); + .shape({ ...hotkeySchema }) + .test( + 'duplicate-hotkeys', + 'Duplicate button combinations are not allowed', + function (currentValue) { + return !Object.entries(this.parent).some( + ([key, { buttonsMask, auxMask }]) => { + if ( + !key.includes('hotkey') || // Skip non-hotkey rows + key === 'hotkey' + number || // Skip current hotkey + !Boolean(currentValue.buttonsMask + currentValue.auxMask) // Skip unset hotkey rows + ) { + return false; + } + return ( + buttonsMask === currentValue.buttonsMask && + auxMask === currentValue.auxMask + ); + }, + ); + }, + ); acc['hotkey' + number] = newSchema; return acc; }, {}); @@ -1678,18 +1699,25 @@ export default function SettingsPage() { {t('SettingsPage:hotkey-settings-warning')} )} -