Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: 24375 Navigation arrows are not shown on PDF until navigated to an image #25529

Merged
merged 5 commits into from
Aug 24, 2023
Merged
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -7,6 +7,11 @@ 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);
// eslint-disable-next-line react-hooks/exhaustive-deps -- we just want to call this function when component is mounted
}, []);

const onScaleChanged = useCallback(
(scale) => {
onScaleChangedProp();
Expand All @@ -15,6 +20,8 @@ function AttachmentViewPdf({file, encryptedSourceUrl, isFocused, isUsedInCarouse
if (isUsedInCarousel) {
const shouldPagerScroll = scale === 1;

attachmentCarouselPagerContext.onPinchGestureChange(scale !== 1);

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we set shouldPagerScroll to be scale === 1 wouldn't it be easier to do this

Suggested change
attachmentCarouselPagerContext.onPinchGestureChange(scale !== 1);
attachmentCarouselPagerContext.onPinchGestureChange(!shouldPagerScroll);

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree!

if (attachmentCarouselPagerContext.shouldPagerScroll.value === shouldPagerScroll) return;

attachmentCarouselPagerContext.shouldPagerScroll.value = shouldPagerScroll;
Expand Down
Loading