diff --git a/src/components/Attachments/AttachmentCarousel/CarouselItem.tsx b/src/components/Attachments/AttachmentCarousel/CarouselItem.tsx index a9b5dfb7feb..7d78340d2b5 100644 --- a/src/components/Attachments/AttachmentCarousel/CarouselItem.tsx +++ b/src/components/Attachments/AttachmentCarousel/CarouselItem.tsx @@ -83,7 +83,6 @@ function CarouselItem({item, onPress, isFocused, isModalHovered}: CarouselItemPr isHovered={isModalHovered} isFocused={isFocused} duration={item.duration} - isUsedInCarousel /> diff --git a/src/components/Attachments/AttachmentCarousel/Pager/index.tsx b/src/components/Attachments/AttachmentCarousel/Pager/index.tsx index 0b6b67b3811..773559c3c5f 100644 --- a/src/components/Attachments/AttachmentCarousel/Pager/index.tsx +++ b/src/components/Attachments/AttachmentCarousel/Pager/index.tsx @@ -53,12 +53,11 @@ function AttachmentCarouselPager( {items, activeSource, initialPage, setShouldShowArrows, onPageSelected, onClose}: AttachmentCarouselPagerProps, ref: ForwardedRef, ) { - const {handleTap, handleScaleChange} = useCarouselContextEvents(setShouldShowArrows); + const {handleTap, handleScaleChange, isScrollEnabled} = useCarouselContextEvents(setShouldShowArrows); const styles = useThemeStyles(); const pagerRef = useRef(null); const isPagerScrolling = useSharedValue(false); - const isScrollEnabled = useSharedValue(true); const activePage = useSharedValue(initialPage); const [activePageIndex, setActivePageIndex] = useState(initialPage); diff --git a/src/components/Attachments/AttachmentCarousel/useCarouselContextEvents.ts b/src/components/Attachments/AttachmentCarousel/useCarouselContextEvents.ts index cc2c3c5c822..1c54d784134 100644 --- a/src/components/Attachments/AttachmentCarousel/useCarouselContextEvents.ts +++ b/src/components/Attachments/AttachmentCarousel/useCarouselContextEvents.ts @@ -58,7 +58,7 @@ function useCarouselContextEvents(setShouldShowArrows: (show?: SetStateAction & { +type AttachmentViewPdfProps = Pick & { encryptedSourceUrl: string; onLoadComplete: (path: string) => void; diff --git a/src/components/Attachments/AttachmentView/index.tsx b/src/components/Attachments/AttachmentView/index.tsx index 39c25706bbf..cd1b52b5224 100644 --- a/src/components/Attachments/AttachmentView/index.tsx +++ b/src/components/Attachments/AttachmentView/index.tsx @@ -1,9 +1,10 @@ import {Str} from 'expensify-common'; -import React, {memo, useEffect, useState} from 'react'; +import React, {memo, useContext, useEffect, useState} from 'react'; import type {GestureResponderEvent, StyleProp, ViewStyle} from 'react-native'; import {View} from 'react-native'; import type {OnyxEntry} from 'react-native-onyx'; import {withOnyx} from 'react-native-onyx'; +import AttachmentCarouselPagerContext from '@components/Attachments/AttachmentCarousel/Pager/AttachmentCarouselPagerContext'; import type {Attachment, AttachmentSource} from '@components/Attachments/types'; import DistanceEReceipt from '@components/DistanceEReceipt'; import EReceipt from '@components/EReceipt'; @@ -42,9 +43,6 @@ type AttachmentViewProps = AttachmentViewOnyxProps & /** Function for handle on press */ onPress?: (e?: GestureResponderEvent | KeyboardEvent) => void; - /** Whether this AttachmentView is shown as part of a AttachmentCarousel */ - isUsedInCarousel?: boolean; - isUsedInAttachmentModal?: boolean; /** Flag to show/hide download icon */ @@ -89,7 +87,6 @@ function AttachmentView({ containerStyles, onToggleKeyboard, isFocused, - isUsedInCarousel, isUsedInAttachmentModal, isWorkspaceAvatar, maybeIcon, @@ -103,6 +100,7 @@ function AttachmentView({ }: AttachmentViewProps) { const {translate} = useLocalize(); const {updateCurrentlyPlayingURL} = usePlaybackContext(); + const attachmentCarouselPagerContext = useContext(AttachmentCarouselPagerContext); const theme = useTheme(); const styles = useThemeStyles(); const StyleUtils = useStyleUtils(); @@ -110,6 +108,7 @@ function AttachmentView({ const [isHighResolution, setIsHighResolution] = useState(false); const [hasPDFFailedToLoad, setHasPDFFailedToLoad] = useState(false); const isVideo = (typeof source === 'string' && Str.isVideo(source)) || (file?.name && Str.isVideo(file.name)); + const isUsedInCarousel = !!attachmentCarouselPagerContext?.pagerRef; useEffect(() => { if (!isFocused && !(file && isUsedInAttachmentModal)) {