diff options
| author | dakkar <dakkar@thenautilus.net> | 2024-11-22 12:29:04 +0000 |
|---|---|---|
| committer | dakkar <dakkar@thenautilus.net> | 2024-11-22 12:29:04 +0000 |
| commit | bc816cb166d907d38eb096a02c5f4f57d9a2f1a0 (patch) | |
| tree | a0e6b1dfeed8aa2b0543846eb65b8aae0ce631ad /packages/frontend/src/scripts/device-kind.ts | |
| parent | better wording for moderator inactivity messages (diff) | |
| parent | Release: 2024.11.0 (diff) | |
| download | sharkey-bc816cb166d907d38eb096a02c5f4f57d9a2f1a0.tar.gz sharkey-bc816cb166d907d38eb096a02c5f4f57d9a2f1a0.tar.bz2 sharkey-bc816cb166d907d38eb096a02c5f4f57d9a2f1a0.zip | |
Merge tag '2024.11.0' into feature/2024.10
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; +} |