Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
324f72f
fix(chat): show offline message when opening video without connection
nabi-ebrahimi May 6, 2026
2e27e96
Merge branch 'main' into fix/chat-offline-message-missing-video-open
nabi-ebrahimi May 7, 2026
778c932
fix prettier
nabi-ebrahimi May 7, 2026
a819e3c
simplify isLocalVideoSource condition
nabi-ebrahimi May 7, 2026
c9a4894
Merge branch 'main' into fix/chat-offline-message-missing-video-open
nabi-ebrahimi May 9, 2026
e831599
Merge branch 'main' into fix/chat-offline-message-missing-video-open
nabi-ebrahimi May 14, 2026
28cfce5
Merge branch 'main' into fix/chat-offline-message-missing-video-open
nabi-ebrahimi May 21, 2026
d8fbe7e
Fix offline video handling in chat preview
nabi-ebrahimi May 21, 2026
3770f28
Merge branch 'main' into fix/chat-offline-message-missing-video-open
nabi-ebrahimi May 28, 2026
c15c563
Merge branch 'main' into fix/chat-offline-message-missing-video-open
nabi-ebrahimi Jun 1, 2026
9e9652c
Fix cached video playback while offline
nabi-ebrahimi Jun 1, 2026
7098de7
remove un used import
nabi-ebrahimi Jun 1, 2026
fc2211b
Merge branch 'main' into fix/chat-offline-message-missing-video-open
nabi-ebrahimi Jun 1, 2026
1edba9f
Merge branch 'main' into fix/chat-offline-message-missing-video-open
nabi-ebrahimi Jun 1, 2026
f4e056a
Merge branch 'main' into fix/chat-offline-message-missing-video-open
nabi-ebrahimi Jun 2, 2026
5c7a959
Merge branch 'main' into fix/chat-offline-message-missing-video-open
nabi-ebrahimi Jun 3, 2026
3fa5232
Merge branch 'main' into fix/chat-offline-message-missing-video-open
nabi-ebrahimi Jun 9, 2026
b852ae5
Merge branch 'main' into fix/chat-offline-message-missing-video-open
nabi-ebrahimi Jun 10, 2026
1584122
Fix offline video preview overlay on small screens
nabi-ebrahimi Jun 10, 2026
6056f55
Merge branch 'main' into fix/chat-offline-message-missing-video-open
nabi-ebrahimi Jun 12, 2026
78e1284
Fix offline video player rendering logic for consistent display
nabi-ebrahimi Jun 12, 2026
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
18 changes: 12 additions & 6 deletions src/components/VideoPlayer/BaseVideoPlayer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@ function BaseVideoPlayer(props: BaseVideoPlayerProps) {
const report = useReportOrReportDraft(reportID);

const isOffline = useNetwork().isOffline;
const [isVideoOffline, setIsVideoOffline] = useState(false);
// A player mounted while already offline should not auto-play content retained in the browser cache.
const [isVideoOffline, setIsVideoOffline] = useState(() => isOffline);
const session = useSession();
const encryptedAuthToken = session?.encryptedAuthToken ?? '';
const [duration, setDuration] = useState(videoDuration);
Expand Down Expand Up @@ -94,7 +95,7 @@ function BaseVideoPlayer(props: BaseVideoPlayerProps) {
// `useEvent` — direct `.playing` read wouldn't re-render when play state changes.
const {isPlaying} = useEvent(videoPlayerRef.current, 'playingChange', {isPlaying: videoPlayerRef.current.playing, oldIsPlaying: false} as PlayingChangeEventPayload);

const {currentTime, bufferedPosition} = useEvent(videoPlayerRef.current, 'timeUpdate', {currentTime: 0, bufferedPosition: 0} as TimeUpdateEventPayload);
const {currentTime} = useEvent(videoPlayerRef.current, 'timeUpdate', {currentTime: 0, bufferedPosition: 0} as TimeUpdateEventPayload);
const {status} = useEvent(videoPlayerRef.current, 'statusChange', {status: shouldUseSharedVideoElement ? playerStatus.current : 'loading'} as StatusChangeEventPayload);

const isLoading = useMemo(() => {
Expand Down Expand Up @@ -161,8 +162,9 @@ function BaseVideoPlayer(props: BaseVideoPlayerProps) {
return isLoading && (!isPlaying || currentTime <= 0) && !isVideoOffline && !hasError;
}, [currentTime, hasError, isLoading, isVideoOffline, isPlaying]);
const shouldShowOfflineIndicator = useMemo(() => {
return isVideoOffline && currentTime + bufferedPosition <= 0;
}, [bufferedPosition, currentTime, isVideoOffline]);
return isVideoOffline && !isPlaying;
}, [isPlaying, isVideoOffline]);

const {updateVolume} = useVolumeActions();
const {lastNonZeroVolume} = useVolumeState();
useHandleNativeVideoControls({
Expand All @@ -172,6 +174,10 @@ function BaseVideoPlayer(props: BaseVideoPlayerProps) {
});

const togglePlayCurrentVideo = useCallback(() => {
if (isOffline) {
return;
}

if (!isCurrentlyURLSet) {
updateCurrentURLAndReportID(url, report, reportID);
return;
Expand All @@ -195,7 +201,7 @@ function BaseVideoPlayer(props: BaseVideoPlayerProps) {

allowSharedAutoPlayRef.current = true;
playVideo();
}, [isCurrentlyURLSet, isLoading, isEnded, currentTime, duration, playVideo, updateCurrentURLAndReportID, url, report, reportID, pauseVideo, replayVideo]);
}, [isOffline, isCurrentlyURLSet, isLoading, isEnded, currentTime, duration, playVideo, updateCurrentURLAndReportID, url, report, reportID, pauseVideo, replayVideo]);

const hideControl = useCallback(() => {
if (isEnded || isSeeking) {
Expand Down Expand Up @@ -294,7 +300,7 @@ function BaseVideoPlayer(props: BaseVideoPlayerProps) {
setHasErrorIconVisible(false);
if (isFirstLoad) {
setIsFirstLoad(false);
if (videoPlayerRef.current === currentVideoPlayerRef.current && !isUploading) {
if (videoPlayerRef.current === currentVideoPlayerRef.current && !isUploading && !isOffline) {
playVideo();
}
}
Expand Down
7 changes: 6 additions & 1 deletion src/components/VideoPlayerPreview/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {usePlaybackActionsContext, usePlaybackStateContext} from '@components/Vi
import useCheckIfRouteHasRemainedUnchanged from '@hooks/useCheckIfRouteHasRemainedUnchanged';
import {useMemoizedLazyExpensifyIcons} from '@hooks/useLazyAsset';
import useLocalize from '@hooks/useLocalize';
import useNetwork from '@hooks/useNetwork';
import useReportOrReportDraft from '@hooks/useReportOrReportDraft';
import useResponsiveLayout from '@hooks/useResponsiveLayout';
import useThemeStyles from '@hooks/useThemeStyles';
Expand Down Expand Up @@ -67,6 +68,10 @@ function VideoPlayerPreview({videoUrl, thumbnailUrl, reportID, fileName, videoDi
const {thumbnailDimensionsStyles} = useThumbnailDimensions(measuredDimensions.width, measuredDimensions.height);
const isOnSearch = useIsOnSearch();
const navigation = useNavigation();
const {isOffline} = useNetwork();

// While offline, render BaseVideoPlayer instead of the thumbnail so the existing player-level offline state is shown consistently.
const shouldRenderVideoPlayer = !isDeleted && (isOffline || (!isSmallScreenWidth && !isThumbnail));

useEffect(() => {
if (!videoUrl || getPlatform() !== CONST.PLATFORM.WEB) {
Expand Down Expand Up @@ -127,7 +132,7 @@ function VideoPlayerPreview({videoUrl, thumbnailUrl, reportID, fileName, videoDi

return (
<View style={[styles.webViewStyles.tagStyles.video, thumbnailDimensionsStyles]}>
{isSmallScreenWidth || isThumbnail || isDeleted ? (
{!shouldRenderVideoPlayer ? (
<VideoPlayerThumbnail
thumbnailUrl={thumbnailUrl}
onPress={handleOnPress}
Expand Down
Loading