From 0922f4a848af3bb5edbdd9c9c6856ff9c89b8884 Mon Sep 17 00:00:00 2001 From: nkdengineer Date: Thu, 23 Jul 2026 23:34:21 +0700 Subject: [PATCH 1/5] fix video preview thumbnail size --- src/components/VideoPlayerPreview/index.tsx | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/components/VideoPlayerPreview/index.tsx b/src/components/VideoPlayerPreview/index.tsx index 25575a24a64e..3255e331c1af 100644 --- a/src/components/VideoPlayerPreview/index.tsx +++ b/src/components/VideoPlayerPreview/index.tsx @@ -1,6 +1,8 @@ +import {useSession} from '@components/OnyxListItemProvider'; import {useIsOnSearch} from '@components/Search/SearchScopeProvider'; import VideoPlayer from '@components/VideoPlayer'; import IconButton from '@components/VideoPlayer/IconButton'; +import {addSkipTimeTagToURL} from '@components/VideoPlayer/utils'; import {usePlaybackActionsContext, usePlaybackStateContext} from '@components/VideoPlayerContexts/PlaybackContext'; import useCheckIfRouteHasRemainedUnchanged from '@hooks/useCheckIfRouteHasRemainedUnchanged'; @@ -12,6 +14,7 @@ import useResponsiveLayout from '@hooks/useResponsiveLayout'; import useThemeStyles from '@hooks/useThemeStyles'; import useThumbnailDimensions from '@hooks/useThumbnailDimensions'; +import addEncryptedAuthTokenToURL from '@libs/addEncryptedAuthTokenToURL'; import getPlatform from '@libs/getPlatform'; import Navigation from '@navigation/Navigation'; @@ -76,12 +79,17 @@ function VideoPlayerPreview({videoUrl, thumbnailUrl, reportID, fileName, videoDi const isOnSearch = useIsOnSearch(); const navigation = useNavigation(); const {isOffline} = useNetwork(); + const session = useSession(); + const encryptedAuthToken = session?.encryptedAuthToken ?? ''; + const [sourceURL] = useState(() => + videoUrl.includes('blob:') || videoUrl.includes('file:///') ? videoUrl : addSkipTimeTagToURL(addEncryptedAuthTokenToURL(videoUrl, encryptedAuthToken), 0.001), + ); // 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) { + if (!sourceURL || getPlatform() !== CONST.PLATFORM.WEB) { return; } const video = document.createElement('video'); @@ -94,12 +102,12 @@ function VideoPlayerPreview({videoUrl, thumbnailUrl, reportID, fileName, videoDi height: video.videoHeight, }); }; - video.src = videoUrl; + video.src = sourceURL; video.load(); return () => { video.src = ''; }; - }, [videoUrl, videoDimensions.width, videoDimensions.height]); + }, [sourceURL, videoDimensions.width, videoDimensions.height]); // We want to play the video only when the user is on the page where it was initially rendered const doesUserRemainOnFirstRenderRoute = useCheckIfRouteHasRemainedUnchanged(videoUrl); From 05bbdeebee45552cdd1834de4d01127f12f74f8d Mon Sep 17 00:00:00 2001 From: nkdengineer Date: Tue, 28 Jul 2026 11:39:11 +0700 Subject: [PATCH 2/5] update review comment --- .../VideoPlayer/BaseVideoPlayer.tsx | 6 ++---- src/components/VideoPlayer/utils.ts | 21 ++++++++++++++++++- src/components/VideoPlayerPreview/index.tsx | 7 ++----- 3 files changed, 24 insertions(+), 10 deletions(-) diff --git a/src/components/VideoPlayer/BaseVideoPlayer.tsx b/src/components/VideoPlayer/BaseVideoPlayer.tsx index 50c66c95a14a..0ab5651b86dd 100644 --- a/src/components/VideoPlayer/BaseVideoPlayer.tsx +++ b/src/components/VideoPlayer/BaseVideoPlayer.tsx @@ -13,7 +13,6 @@ import useNetwork from '@hooks/useNetwork'; import useReportOrReportDraft from '@hooks/useReportOrReportDraft'; import useThemeStyles from '@hooks/useThemeStyles'; -import addEncryptedAuthTokenToURL from '@libs/addEncryptedAuthTokenToURL'; import {isSafari} from '@libs/Browser'; import {canUseTouchScreen as canUseTouchScreenLib} from '@libs/DeviceCapabilities'; @@ -33,7 +32,7 @@ import {scheduleOnRN} from 'react-native-worklets'; import type VideoPlayerProps from './types'; import useHandleNativeVideoControls from './useHandleNativeVideoControls'; -import * as VideoUtils from './utils'; +import {buildVideoSourceURL} from './utils'; import VideoErrorIndicator from './VideoErrorIndicator'; import VideoPlayerControls from './VideoPlayerControls'; @@ -78,8 +77,7 @@ function BaseVideoPlayer(props: BaseVideoPlayerProps) { const [duration, setDuration] = useState(videoDuration); const [isEnded, setIsEnded] = useState(false); const [isFirstLoad, setIsFirstLoad] = useState(true); - // we add "#t=0.001" at the end of the URL to skip first millisecond of the video and always be able to show proper video preview when video is paused at the beginning - const [sourceURL] = useState(() => VideoUtils.addSkipTimeTagToURL(url.includes('blob:') || url.includes('file:///') ? url : addEncryptedAuthTokenToURL(url, encryptedAuthToken), 0.001)); + const [sourceURL] = useState(() => buildVideoSourceURL(url, encryptedAuthToken)); const isPopoverVisible = useIsPopoverVisible(); const [controlStatusState, setControlStatusState] = useState(controlsStatus); const controlsOpacity = useSharedValue(1); diff --git a/src/components/VideoPlayer/utils.ts b/src/components/VideoPlayer/utils.ts index 20322c385849..e3a20c0e8c67 100644 --- a/src/components/VideoPlayer/utils.ts +++ b/src/components/VideoPlayer/utils.ts @@ -1,5 +1,12 @@ +import addEncryptedAuthTokenToURL from '@libs/addEncryptedAuthTokenToURL'; import {isMobileWebKit} from '@libs/Browser'; +/** + * Skip the first millisecond so a paused video can still show a proper preview frame. + * Applied via a `#t=` URL fragment. + */ +const VIDEO_SKIP_TIME_SECONDS = 0.001; + /** * Converts seconds to '[hours:]minutes:seconds' format */ @@ -24,4 +31,16 @@ function addSkipTimeTagToURL(url: string, seconds: number) { return `${url}#t=${seconds}`; } -export {convertSecondsToTime, addSkipTimeTagToURL}; +/** + * Builds the playable video source URL, preserving local/blob URLs and attaching + * auth + skip-time tags for remote attachments. + */ +function buildVideoSourceURL(url: string, encryptedAuthToken: string) { + if (url.includes('blob:') || url.includes('file:///')) { + return url; + } + + return addSkipTimeTagToURL(addEncryptedAuthTokenToURL(url, encryptedAuthToken), VIDEO_SKIP_TIME_SECONDS); +} + +export {convertSecondsToTime, addSkipTimeTagToURL, buildVideoSourceURL, VIDEO_SKIP_TIME_SECONDS}; diff --git a/src/components/VideoPlayerPreview/index.tsx b/src/components/VideoPlayerPreview/index.tsx index 3255e331c1af..4858bf3d725a 100644 --- a/src/components/VideoPlayerPreview/index.tsx +++ b/src/components/VideoPlayerPreview/index.tsx @@ -2,7 +2,7 @@ import {useSession} from '@components/OnyxListItemProvider'; import {useIsOnSearch} from '@components/Search/SearchScopeProvider'; import VideoPlayer from '@components/VideoPlayer'; import IconButton from '@components/VideoPlayer/IconButton'; -import {addSkipTimeTagToURL} from '@components/VideoPlayer/utils'; +import {buildVideoSourceURL} from '@components/VideoPlayer/utils'; import {usePlaybackActionsContext, usePlaybackStateContext} from '@components/VideoPlayerContexts/PlaybackContext'; import useCheckIfRouteHasRemainedUnchanged from '@hooks/useCheckIfRouteHasRemainedUnchanged'; @@ -14,7 +14,6 @@ import useResponsiveLayout from '@hooks/useResponsiveLayout'; import useThemeStyles from '@hooks/useThemeStyles'; import useThumbnailDimensions from '@hooks/useThumbnailDimensions'; -import addEncryptedAuthTokenToURL from '@libs/addEncryptedAuthTokenToURL'; import getPlatform from '@libs/getPlatform'; import Navigation from '@navigation/Navigation'; @@ -81,9 +80,7 @@ function VideoPlayerPreview({videoUrl, thumbnailUrl, reportID, fileName, videoDi const {isOffline} = useNetwork(); const session = useSession(); const encryptedAuthToken = session?.encryptedAuthToken ?? ''; - const [sourceURL] = useState(() => - videoUrl.includes('blob:') || videoUrl.includes('file:///') ? videoUrl : addSkipTimeTagToURL(addEncryptedAuthTokenToURL(videoUrl, encryptedAuthToken), 0.001), - ); + const sourceURL = buildVideoSourceURL(videoUrl, encryptedAuthToken); // While offline, render BaseVideoPlayer instead of the thumbnail so the existing player-level offline state is shown consistently. const shouldRenderVideoPlayer = !isDeleted && (isOffline || (!isSmallScreenWidth && !isThumbnail)); From 4f427ace62c76543db8eca5b65752f41cddb9052 Mon Sep 17 00:00:00 2001 From: nkdengineer Date: Tue, 28 Jul 2026 11:59:14 +0700 Subject: [PATCH 3/5] fix knip check --- src/components/VideoPlayer/utils.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/VideoPlayer/utils.ts b/src/components/VideoPlayer/utils.ts index e3a20c0e8c67..37036be02a03 100644 --- a/src/components/VideoPlayer/utils.ts +++ b/src/components/VideoPlayer/utils.ts @@ -43,4 +43,4 @@ function buildVideoSourceURL(url: string, encryptedAuthToken: string) { return addSkipTimeTagToURL(addEncryptedAuthTokenToURL(url, encryptedAuthToken), VIDEO_SKIP_TIME_SECONDS); } -export {convertSecondsToTime, addSkipTimeTagToURL, buildVideoSourceURL, VIDEO_SKIP_TIME_SECONDS}; +export {convertSecondsToTime, buildVideoSourceURL}; From d8fda0f9e75fd49838f0e2287bdeeb89d5066798 Mon Sep 17 00:00:00 2001 From: nkdengineer Date: Wed, 12 Aug 2026 15:15:18 +0700 Subject: [PATCH 4/5] addSkipTimeTagToURL for local source --- src/components/VideoPlayer/utils.ts | 9 +++++---- src/libs/ReportUtils.ts | 1 + src/libs/actions/Report/index.ts | 2 ++ 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/components/VideoPlayer/utils.ts b/src/components/VideoPlayer/utils.ts index 37036be02a03..f3da3d20697f 100644 --- a/src/components/VideoPlayer/utils.ts +++ b/src/components/VideoPlayer/utils.ts @@ -32,15 +32,16 @@ function addSkipTimeTagToURL(url: string, seconds: number) { } /** - * Builds the playable video source URL, preserving local/blob URLs and attaching - * auth + skip-time tags for remote attachments. + * Builds the playable video source URL. Remote attachments get an auth token. + * All URLs get the skip-time tag when supported. */ function buildVideoSourceURL(url: string, encryptedAuthToken: string) { - if (url.includes('blob:') || url.includes('file:///')) { + if (!url) { return url; } - return addSkipTimeTagToURL(addEncryptedAuthTokenToURL(url, encryptedAuthToken), VIDEO_SKIP_TIME_SECONDS); + const sourceWithAuth = url.includes('blob:') || url.includes('file:///') ? url : addEncryptedAuthTokenToURL(url, encryptedAuthToken); + return addSkipTimeTagToURL(sourceWithAuth, VIDEO_SKIP_TIME_SECONDS); } export {convertSecondsToTime, buildVideoSourceURL}; diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index 3b72b80cb8c0..a2979628f960 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -6719,6 +6719,7 @@ function buildOptimisticAddCommentReportAction({ const commentText = isHTML ? (text ?? '') : getParsedComment(text ?? '', {reportID}); const attachmentHtml = getUploadingAttachmentHtml(file, attachmentID); + console.log('attachmentHtml', attachmentHtml); const htmlForNewComment = `${commentText}${commentText && attachmentHtml ? '

' : ''}${attachmentHtml}`; const textForNewComment = Parser.htmlToText(htmlForNewComment); diff --git a/src/libs/actions/Report/index.ts b/src/libs/actions/Report/index.ts index c6444a583a3e..0b1308f46b93 100644 --- a/src/libs/actions/Report/index.ts +++ b/src/libs/actions/Report/index.ts @@ -938,6 +938,7 @@ function addActions({ lastActionCreated, }); attachmentAction = attachment.reportAction; + console.log('caching attachment', attachmentAction); cacheAttachment({attachmentID, uri: file.uri ?? '', mimeType: file.type}); } @@ -1152,6 +1153,7 @@ function addActions({ DateUtils.setTimezoneUpdated(); } + console.log('writing command', commandName, parameters); API.write(commandName, parameters, { optimisticData, successData, From 38c10659db4bc53f687c093bc05f755643c94ae7 Mon Sep 17 00:00:00 2001 From: nkdengineer Date: Wed, 12 Aug 2026 15:47:08 +0700 Subject: [PATCH 5/5] remove log --- src/libs/ReportUtils.ts | 1 - src/libs/actions/Report/index.ts | 2 -- 2 files changed, 3 deletions(-) diff --git a/src/libs/ReportUtils.ts b/src/libs/ReportUtils.ts index a2979628f960..3b72b80cb8c0 100644 --- a/src/libs/ReportUtils.ts +++ b/src/libs/ReportUtils.ts @@ -6719,7 +6719,6 @@ function buildOptimisticAddCommentReportAction({ const commentText = isHTML ? (text ?? '') : getParsedComment(text ?? '', {reportID}); const attachmentHtml = getUploadingAttachmentHtml(file, attachmentID); - console.log('attachmentHtml', attachmentHtml); const htmlForNewComment = `${commentText}${commentText && attachmentHtml ? '

' : ''}${attachmentHtml}`; const textForNewComment = Parser.htmlToText(htmlForNewComment); diff --git a/src/libs/actions/Report/index.ts b/src/libs/actions/Report/index.ts index 0b1308f46b93..c6444a583a3e 100644 --- a/src/libs/actions/Report/index.ts +++ b/src/libs/actions/Report/index.ts @@ -938,7 +938,6 @@ function addActions({ lastActionCreated, }); attachmentAction = attachment.reportAction; - console.log('caching attachment', attachmentAction); cacheAttachment({attachmentID, uri: file.uri ?? '', mimeType: file.type}); } @@ -1153,7 +1152,6 @@ function addActions({ DateUtils.setTimezoneUpdated(); } - console.log('writing command', commandName, parameters); API.write(commandName, parameters, { optimisticData, successData,