Skip to content

Commit bb771bd

Browse files
authored
only show previews on non png (keybase#26679)
1 parent f0f201f commit bb771bd

3 files changed

Lines changed: 7 additions & 4 deletions

File tree

‎shared/chat/conversation/attachment-fullscreen/hooks.tsx‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ export const useData = (initialOrdinal: T.Chat.Ordinal) => {
4040
const navigateUp = C.useRouterState(s => s.dispatch.navigateUp)
4141
const showInfoPanel = C.useChatContext(s => s.dispatch.showInfoPanel)
4242
const attachmentDownload = C.useChatContext(s => s.dispatch.attachmentDownload)
43-
const {downloadPath, fileURL: path, fullHeight, fullWidth} = message
43+
const {downloadPath, fileURL: path, fullHeight, fullWidth, fileType} = message
4444
const {previewHeight, previewURL: previewPath, previewWidth, title, transferProgress} = message
4545
const {height: clampedHeight, width: clampedWidth} = C.Chat.clampImageSize(
4646
previewWidth,
@@ -49,6 +49,7 @@ export const useData = (initialOrdinal: T.Chat.Ordinal) => {
4949
maxHeight
5050
)
5151
const isVideo = C.Chat.isVideoAttachment(message)
52+
const showPreview = !fileType.includes('png')
5253
const onAllMedia = () => showInfoPanel(true, 'attachments')
5354
const onClose = () => navigateUp()
5455
const onDownloadAttachment = message.downloadPath
@@ -86,6 +87,7 @@ export const useData = (initialOrdinal: T.Chat.Ordinal) => {
8687
previewWidth: clampedWidth,
8788
progress,
8889
progressLabel,
90+
showPreview,
8991
title: message.decoratedText ? message.decoratedText.stringValue() : title,
9092
}
9193
}
@@ -95,10 +97,11 @@ export const usePreviewFallback = (
9597
path: string,
9698
previewPath: string,
9799
isVideo: boolean,
100+
showPreview: boolean,
98101
preload: (path: string, onLoad: () => void, onError: () => void) => void
99102
) => {
100103
const [imgSrc, setImgSrc] = React.useState('')
101-
const canUseFallback = path && previewPath && !isVideo
104+
const canUseFallback = path && previewPath && !isVideo && showPreview
102105

103106
React.useEffect(() => {
104107
const onLoad = () => {

‎shared/chat/conversation/attachment-fullscreen/index.desktop.tsx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ const Fullscreen = React.memo(function Fullscreen(p: Props) {
5050
img.onerror = onError
5151
}, [])
5252

53-
const imgSrc = usePreviewFallback(path, previewPath, isVideo, preload)
53+
const imgSrc = usePreviewFallback(path, previewPath, isVideo, data.showPreview, preload)
5454

5555
const forceDims = React.useMemo(() => {
5656
if (!previewWidth) return undefined

‎shared/chat/conversation/attachment-fullscreen/index.native.tsx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ const Fullscreen = (p: Props) => {
3636
.catch(() => {})
3737
}, [])
3838

39-
const imgSrc = usePreviewFallback(path, previewPath, isVideo, preload)
39+
const imgSrc = usePreviewFallback(path, previewPath, isVideo, data.showPreview, preload)
4040
const {showPopup, popup} = useMessagePopup({ordinal})
4141

4242
const onSwipe = React.useCallback(

0 commit comments

Comments
 (0)