|
1 | 1 | import type { JSX } from 'react' |
2 | | -import { useState, useRef, useEffect } from 'react' |
| 2 | +import { useState, useRef } from 'react' |
3 | 3 | import { css } from '../../../../utils/css' |
4 | 4 |
|
5 | 5 | const SUCCESS_SHOW_DELAY_MS = 180 |
@@ -308,25 +308,13 @@ function parseKeyCode(code: string | JSX.Element) { |
308 | 308 | } |
309 | 309 |
|
310 | 310 | function MetaKey() { |
311 | | - // u00A0 = |
312 | | - const [label, setLabel] = useState('\u00A0') |
313 | | - |
314 | | - const apple = isApple() |
315 | | - |
316 | | - useEffect(() => { |
317 | | - // Meta is Command on Apple devices, otherwise Control |
318 | | - if (apple === true) { |
319 | | - // eslint-disable-next-line react-hooks/set-state-in-effect -- TODO |
320 | | - setLabel('⌘') |
321 | | - } |
322 | | - |
323 | | - // Explicitly say "Ctrl" instead of the symbol "⌃" |
324 | | - // because most Windows/Linux laptops do not print the symbol |
325 | | - // Other keyboard-intensive apps like Linear do this |
326 | | - if (apple === false) { |
327 | | - setLabel('Ctrl') |
328 | | - } |
329 | | - }, [apple]) |
| 311 | + const label = isApple() |
| 312 | + ? // Meta is Command on Apple devices, otherwise Control |
| 313 | + '⌘' |
| 314 | + : // Explicitly say "Ctrl" instead of the symbol "⌃" |
| 315 | + // because most Windows/Linux laptops do not print the symbol |
| 316 | + // Other keyboard-intensive apps like Linear do this |
| 317 | + 'Ctrl' |
330 | 318 |
|
331 | 319 | return ( |
332 | 320 | <span style={{ minWidth: '1em', display: 'inline-block' }}>{label}</span> |
@@ -499,8 +487,7 @@ export const SHORTCUT_RECORDER_STYLES = css` |
499 | 487 | /////////////////////////////////////////////////////////////////////////////////////////////////// |
500 | 488 |
|
501 | 489 | function testPlatform(re: RegExp): boolean | undefined { |
502 | | - // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition -- Checking on an unusual environment. |
503 | | - return typeof window !== 'undefined' && window.navigator != null |
| 490 | + return window.navigator != null |
504 | 491 | ? re.test(window.navigator.platform) |
505 | 492 | : undefined |
506 | 493 | } |
|
0 commit comments