Skip to content

Commit

Permalink
Scroll is broken on HA iPad app
Browse files Browse the repository at this point in the history
Fixes #110
  • Loading branch information
andrew-codes committed Jan 23, 2024
1 parent 58f2dad commit bc8dd42
Showing 1 changed file with 28 additions and 2 deletions.
30 changes: 28 additions & 2 deletions apps/playnite-web/src/root.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
ScrollRestoration,
useLoaderData,
} from '@remix-run/react'
import { FC } from 'react'
import { FC, useEffect, useState } from 'react'
import { Provider } from 'react-redux'
import { createHead } from 'remix-island'
import { authenticator } from './api/auth/auth.server'
Expand Down Expand Up @@ -75,13 +75,39 @@ const Head = createHead(() => (
))

const App: FC<{}> = () => {
const { deviceType, user } = useLoaderData<{
const { deviceType: serverDeviceType, user } = useLoaderData<{
deviceType: 'mobile' | 'tablet' | 'desktop' | 'unknown'
user?: any
}>()

const store = configureStore({ reducer })

const [deviceType, setDeviceTypeState] = useState<
'mobile' | 'tablet' | 'desktop' | 'unknown' | null
>(serverDeviceType)
useEffect(() => {
if (
!!navigator &&
'maxTouchPoints' in navigator &&
navigator.maxTouchPoints > 0
) {
setDeviceTypeState('tablet')
} else if (
!!navigator &&
'msMaxTouchPoints' in navigator &&
(navigator as unknown as any).msMaxTouchPoints > 0
) {
setDeviceTypeState('tablet')
} else {
const mQ = matchMedia?.('(pointer:coarse)')
if (mQ?.media === '(pointer:coarse)' && !!mQ.matches) {
setDeviceTypeState('tablet')
} else if ('orientation' in window) {
setDeviceTypeState('tablet')
}
}
}, [])

store.dispatch(setDeviceType(deviceType))

if (!!user) {
Expand Down

0 comments on commit bc8dd42

Please sign in to comment.