From d5f8711ab305df1ee7f19d570717e3bc067f0369 Mon Sep 17 00:00:00 2001 From: tienifr Date: Sat, 12 Aug 2023 13:34:01 +0700 Subject: [PATCH 1/4] fix: 24375 --- .../AttachmentView/AttachmentViewPdf/index.native.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/components/Attachments/AttachmentView/AttachmentViewPdf/index.native.js b/src/components/Attachments/AttachmentView/AttachmentViewPdf/index.native.js index dc329a9fd3fd..86bd3e08cf20 100644 --- a/src/components/Attachments/AttachmentView/AttachmentViewPdf/index.native.js +++ b/src/components/Attachments/AttachmentView/AttachmentViewPdf/index.native.js @@ -1,4 +1,4 @@ -import React, {memo, useCallback, useContext} from 'react'; +import React, {memo, useCallback, useContext, useEffect} from 'react'; import styles from '../../../../styles/styles'; import {attachmentViewPdfPropTypes, attachmentViewPdfDefaultProps} from './propTypes'; import PDFView from '../../../PDFView'; @@ -7,14 +7,21 @@ import AttachmentCarouselPagerContext from '../../AttachmentCarousel/Pager/Attac function AttachmentViewPdf({file, encryptedSourceUrl, isFocused, isUsedInCarousel, onPress, onScaleChanged: onScaleChangedProp, onToggleKeyboard, onLoadComplete}) { const attachmentCarouselPagerContext = useContext(AttachmentCarouselPagerContext); + useEffect(() => { + attachmentCarouselPagerContext.onPinchGestureChange(false); + }, []); + const onScaleChanged = useCallback( (scale) => { + console.log('onScaleChangeddddddd', scale); onScaleChangedProp(); // When a pdf is shown in a carousel, we want to disable the pager scroll when the pdf is zoomed in if (isUsedInCarousel) { const shouldPagerScroll = scale === 1; + attachmentCarouselPagerContext.onPinchGestureChange(scale !== 1); + if (attachmentCarouselPagerContext.shouldPagerScroll.value === shouldPagerScroll) return; attachmentCarouselPagerContext.shouldPagerScroll.value = shouldPagerScroll; From 80c7d16b228b53ad0d22f9aadf81dd192c2dd458 Mon Sep 17 00:00:00 2001 From: tienifr Date: Sat, 19 Aug 2023 21:57:16 +0700 Subject: [PATCH 2/4] clear console log --- .../Attachments/AttachmentView/AttachmentViewPdf/index.native.js | 1 - 1 file changed, 1 deletion(-) diff --git a/src/components/Attachments/AttachmentView/AttachmentViewPdf/index.native.js b/src/components/Attachments/AttachmentView/AttachmentViewPdf/index.native.js index 86bd3e08cf20..cd2cc4079e12 100644 --- a/src/components/Attachments/AttachmentView/AttachmentViewPdf/index.native.js +++ b/src/components/Attachments/AttachmentView/AttachmentViewPdf/index.native.js @@ -13,7 +13,6 @@ function AttachmentViewPdf({file, encryptedSourceUrl, isFocused, isUsedInCarouse const onScaleChanged = useCallback( (scale) => { - console.log('onScaleChangeddddddd', scale); onScaleChangedProp(); // When a pdf is shown in a carousel, we want to disable the pager scroll when the pdf is zoomed in From 9fc4770b1ef823e403f04ddc24c1ee3bbcf81bda Mon Sep 17 00:00:00 2001 From: tienifr Date: Sat, 19 Aug 2023 22:35:14 +0700 Subject: [PATCH 3/4] fix: eslint error --- .../Attachments/AttachmentView/AttachmentViewPdf/index.native.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/components/Attachments/AttachmentView/AttachmentViewPdf/index.native.js b/src/components/Attachments/AttachmentView/AttachmentViewPdf/index.native.js index cd2cc4079e12..38c1deecb8e0 100644 --- a/src/components/Attachments/AttachmentView/AttachmentViewPdf/index.native.js +++ b/src/components/Attachments/AttachmentView/AttachmentViewPdf/index.native.js @@ -9,6 +9,7 @@ function AttachmentViewPdf({file, encryptedSourceUrl, isFocused, isUsedInCarouse useEffect(() => { attachmentCarouselPagerContext.onPinchGestureChange(false); + // eslint-disable-next-line react-hooks/exhaustive-deps -- we just want to call this function when component is mounted }, []); const onScaleChanged = useCallback( From a9d3d6d6bd97fc2bcb332a38b0501d081f45e0c2 Mon Sep 17 00:00:00 2001 From: tienifr Date: Thu, 24 Aug 2023 04:53:39 +0700 Subject: [PATCH 4/4] refactor condition --- .../AttachmentView/AttachmentViewPdf/index.native.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/Attachments/AttachmentView/AttachmentViewPdf/index.native.js b/src/components/Attachments/AttachmentView/AttachmentViewPdf/index.native.js index 38c1deecb8e0..bf777f41945e 100644 --- a/src/components/Attachments/AttachmentView/AttachmentViewPdf/index.native.js +++ b/src/components/Attachments/AttachmentView/AttachmentViewPdf/index.native.js @@ -20,7 +20,7 @@ function AttachmentViewPdf({file, encryptedSourceUrl, isFocused, isUsedInCarouse if (isUsedInCarousel) { const shouldPagerScroll = scale === 1; - attachmentCarouselPagerContext.onPinchGestureChange(scale !== 1); + attachmentCarouselPagerContext.onPinchGestureChange(!shouldPagerScroll); if (attachmentCarouselPagerContext.shouldPagerScroll.value === shouldPagerScroll) return;