Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
9 changes: 5 additions & 4 deletions src/components/Attachments/AttachmentView/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@
}: AttachmentViewProps) {
const [transaction] = useOnyx(`${ONYXKEYS.COLLECTION.TRANSACTION}${getNonEmptyStringOnyxID(transactionID)}`, {canBeMissing: true});
const {translate} = useLocalize();
const {updateCurrentURLAndReportID, playVideo} = usePlaybackContext();
const {updateCurrentURLAndReportID, currentlyPlayingURL, playVideo} = usePlaybackContext();

const attachmentCarouselPagerContext = useContext(AttachmentCarouselPagerContext);
const {onAttachmentError} = attachmentCarouselPagerContext ?? {};
Expand All @@ -144,11 +144,12 @@
if (!isFocused && !isInFocusedModal && !(file && isUsedInAttachmentModal)) {
return;
}
updateCurrentURLAndReportID(isVideo && typeof source === 'string' ? source : undefined, reportID);
if (isVideo && typeof source === 'string') {
const videoSource = isVideo && typeof source === 'string' ? source : undefined;
updateCurrentURLAndReportID(videoSource, reportID);
if (videoSource && currentlyPlayingURL === videoSource) {
playVideo();
}
}, [file, isFocused, isInFocusedModal, isUsedInAttachmentModal, isVideo, reportID, source, updateCurrentURLAndReportID, playVideo]);
}, [file, isFocused, isInFocusedModal, isUsedInAttachmentModal, isVideo, reportID, source, updateCurrentURLAndReportID, playVideo, currentlyPlayingURL]);

const [imageError, setImageError] = useState(false);

Expand Down Expand Up @@ -312,7 +313,7 @@
</>
);
}
imageSource = previewSource?.toString() ?? imageSource;

Check warning on line 316 in src/components/Attachments/AttachmentView/index.tsx

View workflow job for this annotation

GitHub Actions / ESLint check

'previewSource' may use Object's default stringification format ('[object Object]') when stringified
}

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ function PlaybackContextProvider({children}: ChildrenProps) {

if (!url) {
if (currentlyPlayingURL) {
video.stop();
video.pause();
}
return;
}
Expand Down
Loading