Dont crash reader if items have a webkit element

This commit is contained in:
Jackson Harper
2024-06-11 12:47:12 +08:00
parent 883d6619ea
commit 0b908c4bb1

View File

@ -67,8 +67,9 @@ export function Article(props: ArticleProps): JSX.Element {
const [lightboxOpen, setLightboxOpen] = useState(false)
const [imageSrcs, setImageSrcs] = useState<SlideImage[]>([])
const [lightboxIndex, setlightBoxIndex] = useState(0)
const [linkHoverData, setlinkHoverData] =
useState<LinkHoverData | undefined>()
const [linkHoverData, setlinkHoverData] = useState<
LinkHoverData | undefined
>()
useEffect(() => {
;(async () => {
@ -97,7 +98,10 @@ export function Article(props: ArticleProps): JSX.Element {
// Post message to webkit so apple app embeds get progress updates
// TODO: verify if ios still needs this code...seeems to be duplicated
useEffect(() => {
if (typeof window?.webkit != 'undefined') {
if (
typeof window?.webkit != 'undefined' &&
'messageHandlers' in window.webkit
) {
window.webkit.messageHandlers.readingProgressUpdate?.postMessage({
progress: readingProgress,
})