Skip to content

Commit

Permalink
fix(mobile): PDF preview causing loop when biometrics are set to Imme…
Browse files Browse the repository at this point in the history
…diate (#2080)
  • Loading branch information
amanharwara committed Dec 2, 2022
1 parent 1e8ce4b commit 0c23e4d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 16 deletions.
4 changes: 2 additions & 2 deletions packages/mobile/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -583,7 +583,7 @@ EXTERNAL SOURCES:
SPEC CHECKSUMS:
boost: a7c83b31436843459a1961bfd74b96033dc77234
CocoaAsyncSocket: 065fd1e645c7abab64f7a6a2007a48038fdc6a99
DoubleConversion: 5189b271737e1565bdce30deb4a08d647e3f5f54
DoubleConversion: 831926d9b8bf8166fd87886c4abab286c2422662
FBLazyVector: 48289402952f4f7a4e235de70a9a590aa0b79ef4
FBReactNativeSpec: dd1186fd05255e3457baa2f4ca65e94c2cd1e3ac
Flipper: 26fc4b7382499f1281eb8cb921e5c3ad6de91fe0
Expand All @@ -596,7 +596,7 @@ SPEC CHECKSUMS:
Flipper-RSocket: d9d9ade67cbecf6ac10730304bf5607266dd2541
FlipperKit: cbdee19bdd4e7f05472a66ce290f1b729ba3cb86
fmt: ff9d55029c625d3757ed641535fd4a75fedc7ce9
glog: 04b94705f318337d7ead9e6d17c019bd9b1f6b1b
glog: 85ecdd10ee8d8ec362ef519a6a45ff9aa27b2e85
hermes-engine: 2af7b7a59128f250adfd86f15aa1d5a2ecd39995
libevent: 4049cae6c81cdb3654a443be001fb9bdceff7913
OpenSSL-Universal: ebc357f1e6bc71fa463ccb2fe676756aff50e88c
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ import { getBase64FromBlob } from '@/Utils'
import { FileItem } from '@standardnotes/snjs'
import { FunctionComponent, useCallback, useEffect, useMemo, useRef } from 'react'
import Button from '../Button/Button'
import { AppPaneId } from '../Panes/AppPaneMetadata'
import { useResponsiveAppPane } from '../Panes/ResponsivePaneProvider'
import { createObjectURLWithRef } from './CreateObjectURLWithRef'
import ImagePreview from './ImagePreview'
import { ImageZoomLevelProps } from './ImageZoomLevelProps'
Expand All @@ -26,8 +24,6 @@ const PreviewComponent: FunctionComponent<Props> = ({
imageZoomLevel,
setImageZoomLevel,
}) => {
const { selectedPane } = useResponsiveAppPane()

const objectUrlRef = useRef<string>()

const objectUrl = useMemo(() => {
Expand Down Expand Up @@ -62,20 +58,14 @@ const PreviewComponent: FunctionComponent<Props> = ({
void application.mobileDevice().previewFile(fileBase64, file.name)
}, [application, bytes, file.mimeType, file.name, isNativeMobileWeb])

useEffect(() => {
const shouldOpenNativePreviewOnLoad =
isNativeMobileWeb && selectedPane === AppPaneId.Editor && requiresNativePreview
if (shouldOpenNativePreviewOnLoad) {
void openNativeFilePreview()
}
}, [isNativeMobileWeb, openNativeFilePreview, requiresNativePreview, selectedPane])

if (isNativeMobileWeb && requiresNativePreview) {
return (
<div className="flex flex-grow flex-col items-center justify-center">
<div className="text-base font-bold">Previewing file...</div>
<div className="max-w-[30ch] text-center text-base font-bold">
This file can only be previewed in an external app
</div>
<Button className="mt-3" primary onClick={openNativeFilePreview}>
Re-open file preview
Open file preview
</Button>
</div>
)
Expand Down

0 comments on commit 0c23e4d

Please sign in to comment.