Fix keyboard shortcuts to use Control on Windows and Linux (#3620)

* Fix keyboard shortcuts to use Control instead of Meta on Windows and Linux

* Convert more tests to use Playwright built-in
This commit is contained in:
Jonathan Tran
2024-08-22 19:13:27 -04:00
committed by GitHub
parent e624c9b124
commit acbe92d717
14 changed files with 92 additions and 112 deletions

View File

@ -1,44 +1,11 @@
import { isDesktop } from 'lib/isDesktop'
import { Platform, platform } from 'lib/utils'
import { useEffect, useState } from 'react'
export type Platform = 'macos' | 'windows' | 'linux' | ''
export default function usePlatform() {
const [platformName, setPlatformName] = useState<Platform>('')
useEffect(() => {
function getPlatform(): Platform {
const platform = window.electron.platform ?? ''
// https://nodejs.org/api/process.html#processplatform
switch (platform) {
case 'darwin':
return 'macos'
case 'win32':
return 'windows'
// We don't currently care to distinguish between these.
case 'android':
case 'freebsd':
case 'linux':
case 'openbsd':
case 'sunos':
return 'linux'
default:
console.error('Unknown platform:', platform)
return ''
}
}
if (isDesktop()) {
setPlatformName(getPlatform())
} else {
if (navigator.userAgent.indexOf('Mac') !== -1) {
setPlatformName('macos')
} else if (navigator.userAgent.indexOf('Win') !== -1) {
setPlatformName('windows')
} else if (navigator.userAgent.indexOf('Linux') !== -1) {
setPlatformName('linux')
}
}
setPlatformName(platform())
}, [setPlatformName])
return platformName