From 4e54e815b58fc43a14cfb65129f1233a2529057e Mon Sep 17 00:00:00 2001 From: Krishna Gupta Date: Mon, 26 Feb 2024 09:54:04 +0530 Subject: [PATCH] fix failing video downloads on native. Signed-off-by: Krishna Gupta --- .../VideoPlayerContexts/VideoPopoverMenuContext.js | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/components/VideoPlayerContexts/VideoPopoverMenuContext.js b/src/components/VideoPlayerContexts/VideoPopoverMenuContext.js index ed502136716f..4bb10e526fe4 100644 --- a/src/components/VideoPlayerContexts/VideoPopoverMenuContext.js +++ b/src/components/VideoPlayerContexts/VideoPopoverMenuContext.js @@ -4,15 +4,15 @@ import _ from 'underscore'; import * as Expensicons from '@components/Icon/Expensicons'; import useLocalize from '@hooks/useLocalize'; import useNetwork from '@hooks/useNetwork'; +import addEncryptedAuthTokenToURL from '@libs/addEncryptedAuthTokenToURL'; import fileDownload from '@libs/fileDownload'; -import tryResolveUrlFromApiRoot from '@libs/tryResolveUrlFromApiRoot'; import CONST from '@src/CONST'; import {usePlaybackContext} from './PlaybackContext'; const VideoPopoverMenuContext = React.createContext(null); function VideoPopoverMenuContextProvider({children}) { - const {currentVideoPlayerRef} = usePlaybackContext(); + const {currentVideoPlayerRef, currentlyPlayingURL} = usePlaybackContext(); const {translate} = useLocalize(); const [currentPlaybackSpeed, setCurrentPlaybackSpeed] = useState(CONST.VIDEO_PLAYER.PLAYBACK_SPEEDS[2]); const {isOffline} = useNetwork(); @@ -26,11 +26,9 @@ function VideoPopoverMenuContextProvider({children}) { ); const downloadAttachment = useCallback(() => { - currentVideoPlayerRef.current.getStatusAsync().then((status) => { - const sourceURI = tryResolveUrlFromApiRoot(status.uri); - fileDownload(sourceURI); - }); - }, [currentVideoPlayerRef]); + const sourceURI = currentlyPlayingURL.startsWith('blob:') || currentlyPlayingURL.startsWith('file:') ? currentlyPlayingURL : addEncryptedAuthTokenToURL(currentlyPlayingURL); + fileDownload(sourceURI); + }, [currentlyPlayingURL]); const menuItems = useMemo(() => { const items = [];