diff options
| author | かっこかり <67428053+kakkokari-gtyih@users.noreply.github.com> | 2024-11-09 10:57:04 +0900 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-11-09 10:57:04 +0900 |
| commit | 3a421837bfc8ea816c3109394a916cb0cac0e8d8 (patch) | |
| tree | bc652cc03f6d2198b0ceca208af8a801483066f7 /packages/frontend/src/scripts/device-kind.ts | |
| parent | enhance(backend) : リモートユーザーの照会をオリジナルにリ... (diff) | |
| download | sharkey-3a421837bfc8ea816c3109394a916cb0cac0e8d8.tar.gz sharkey-3a421837bfc8ea816c3109394a916cb0cac0e8d8.tar.bz2 sharkey-3a421837bfc8ea816c3109394a916cb0cac0e8d8.zip | |
refactor(frontend): 動画UIのフルスクリーン周りの調整 (#14877)
* refactor(frontend): フルスクリーン周りの調整
(cherry picked from commit 783032caec5853d78d5af3391e29cf364f2282e8)
* refactor(frontend): deviceKindの循環参照を除去
(cherry picked from commit 1ca471f57e968a1a6e2259bde4a7c6da1fe0c54e)
* fix
---------
Co-authored-by: taiyme <53635909+taiyme@users.noreply.github.com>
Diffstat (limited to 'packages/frontend/src/scripts/device-kind.ts')
| -rw-r--r-- | packages/frontend/src/scripts/device-kind.ts | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/packages/frontend/src/scripts/device-kind.ts b/packages/frontend/src/scripts/device-kind.ts index 7c33f8ccee..7aadb617ca 100644 --- a/packages/frontend/src/scripts/device-kind.ts +++ b/packages/frontend/src/scripts/device-kind.ts @@ -3,22 +3,22 @@ * SPDX-License-Identifier: AGPL-3.0-only */ -import { defaultStore } from '@/store.js'; - -await defaultStore.ready; +export type DeviceKind = 'smartphone' | 'tablet' | 'desktop'; const ua = navigator.userAgent.toLowerCase(); const isTablet = /ipad/.test(ua) || (/mobile|iphone|android/.test(ua) && window.innerWidth > 700); const isSmartphone = !isTablet && /mobile|iphone|android/.test(ua); -const isIPhone = /iphone|ipod/gi.test(ua) && navigator.maxTouchPoints > 1; -// navigator.platform may be deprecated but this check is still required -const isIPadOS = navigator.platform === 'MacIntel' && navigator.maxTouchPoints > 1; -const isIos = /ipad|iphone|ipod/gi.test(ua) && navigator.maxTouchPoints > 1; +export const DEFAULT_DEVICE_KIND: DeviceKind = ( + isSmartphone + ? 'smartphone' + : isTablet + ? 'tablet' + : 'desktop' +); -export const isFullscreenNotSupported = isIPhone || isIos; +export let deviceKind: DeviceKind = DEFAULT_DEVICE_KIND; -export const deviceKind: 'smartphone' | 'tablet' | 'desktop' = defaultStore.state.overridedDeviceKind ? defaultStore.state.overridedDeviceKind - : isSmartphone ? 'smartphone' - : isTablet ? 'tablet' - : 'desktop'; +export function updateDeviceKind(kind: DeviceKind | null) { + deviceKind = kind ?? DEFAULT_DEVICE_KIND; +} |