From 814489073e1566fe95541a637f54b7ad6138b085 Mon Sep 17 00:00:00 2001 From: Krishna Gupta Date: Tue, 20 Feb 2024 21:25:34 +0530 Subject: [PATCH 1/2] fix: Chat - Download option in three-dot menu is still available in offline mode. Signed-off-by: Krishna Gupta --- .../VideoPopoverMenuContext.js | 30 +++++++++++-------- 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/src/components/VideoPlayerContexts/VideoPopoverMenuContext.js b/src/components/VideoPlayerContexts/VideoPopoverMenuContext.js index 23d1aec1817c..9c19ef8ed212 100644 --- a/src/components/VideoPlayerContexts/VideoPopoverMenuContext.js +++ b/src/components/VideoPlayerContexts/VideoPopoverMenuContext.js @@ -3,6 +3,7 @@ import React, {useCallback, useContext, useMemo, useState} from 'react'; import _ from 'underscore'; import * as Expensicons from '@components/Icon/Expensicons'; import useLocalize from '@hooks/useLocalize'; +import useNetwork from '@hooks/useNetwork'; import fileDownload from '@libs/fileDownload'; import * as Url from '@libs/Url'; import CONST from '@src/CONST'; @@ -14,6 +15,7 @@ function VideoPopoverMenuContextProvider({children}) { const {currentVideoPlayerRef} = usePlaybackContext(); const {translate} = useLocalize(); const [currentPlaybackSpeed, setCurrentPlaybackSpeed] = useState(CONST.VIDEO_PLAYER.PLAYBACK_SPEEDS[2]); + const {isOffline} = useNetwork(); const updatePlaybackSpeed = useCallback( (speed) => { @@ -30,15 +32,8 @@ function VideoPopoverMenuContextProvider({children}) { }); }, [currentVideoPlayerRef]); - const menuItems = useMemo( - () => [ - { - icon: Expensicons.Download, - text: translate('common.download'), - onSelected: () => { - downloadAttachment(); - }, - }, + const menuItems = useMemo(() => { + const items = [ { icon: Expensicons.Meter, text: translate('videoPlayer.playbackSpeed'), @@ -53,9 +48,20 @@ function VideoPopoverMenuContextProvider({children}) { })), ], }, - ], - [currentPlaybackSpeed, downloadAttachment, translate, updatePlaybackSpeed], - ); + ]; + + if (!isOffline) { + items.push({ + icon: Expensicons.Download, + text: translate('common.download'), + onSelected: () => { + downloadAttachment(); + }, + }); + } + + return items; + }, [currentPlaybackSpeed, downloadAttachment, translate, updatePlaybackSpeed, isOffline]); const contextValue = useMemo(() => ({menuItems, updatePlaybackSpeed}), [menuItems, updatePlaybackSpeed]); return {children}; From 2f3df12aaf931c54f7964e1f99b52e27c946534a Mon Sep 17 00:00:00 2001 From: Krishna Gupta Date: Thu, 22 Feb 2024 02:31:42 +0530 Subject: [PATCH 2/2] change menu items order. Signed-off-by: Krishna Gupta --- .../VideoPopoverMenuContext.js | 32 +++++++++---------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/src/components/VideoPlayerContexts/VideoPopoverMenuContext.js b/src/components/VideoPlayerContexts/VideoPopoverMenuContext.js index 9c19ef8ed212..801c1b2f44ca 100644 --- a/src/components/VideoPlayerContexts/VideoPopoverMenuContext.js +++ b/src/components/VideoPlayerContexts/VideoPopoverMenuContext.js @@ -33,22 +33,7 @@ function VideoPopoverMenuContextProvider({children}) { }, [currentVideoPlayerRef]); const menuItems = useMemo(() => { - const items = [ - { - icon: Expensicons.Meter, - text: translate('videoPlayer.playbackSpeed'), - subMenuItems: [ - ..._.map(CONST.VIDEO_PLAYER.PLAYBACK_SPEEDS, (speed) => ({ - icon: currentPlaybackSpeed === speed ? Expensicons.Checkmark : null, - text: speed.toString(), - onSelected: () => { - updatePlaybackSpeed(speed); - }, - shouldPutLeftPaddingWhenNoIcon: true, - })), - ], - }, - ]; + const items = []; if (!isOffline) { items.push({ @@ -60,6 +45,21 @@ function VideoPopoverMenuContextProvider({children}) { }); } + items.push({ + icon: Expensicons.Meter, + text: translate('videoPlayer.playbackSpeed'), + subMenuItems: [ + ..._.map(CONST.VIDEO_PLAYER.PLAYBACK_SPEEDS, (speed) => ({ + icon: currentPlaybackSpeed === speed ? Expensicons.Checkmark : null, + text: speed.toString(), + onSelected: () => { + updatePlaybackSpeed(speed); + }, + shouldPutLeftPaddingWhenNoIcon: true, + })), + ], + }); + return items; }, [currentPlaybackSpeed, downloadAttachment, translate, updatePlaybackSpeed, isOffline]);