[Better Expense Report View] Fix video player in expense report view & chat thread#59430
Conversation
|
@DylanDylann Please copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button] |
|
Discussing with @JakubKorytko on Slack to speed it up. WIll give a summary to the GH asap |
|
@DylanDylann I've fixed it according to your comments and also made some changes because this component logic depends on many factors. Please check again |
|
BUG: Can't play video after reloading the attachment view Screen.Recording.2025-04-05.at.00.01.43.mov |
Reviewer Checklist
Screenshots/VideosAndroid: NativeScreen.Recording.2025-04-05.at.00.06.32.movAndroid: mWeb ChromeScreen.Recording.2025-04-05.at.00.00.02.moviOS: NativeScreen.Recording.2025-04-05.at.01.15.46.moviOS: mWeb SafariScreen.Recording.2025-04-05.at.00.01.43.movMacOS: Chrome / SafariScreen.Recording.2025-04-04.at.23.56.09.movMacOS: DesktopScreen.Recording.2025-04-04.at.23.57.01.mov |
Fixed |
mountiny
left a comment
There was a problem hiding this comment.
Leaving some NABs that you could address in future PRs
| const attachmentReportID = Navigation.getActiveRouteWithoutParams() === `/${ROUTES.ATTACHMENTS.route}` ? prevCurrentReportID ?? reportIDFromUrlParams : undefined; | ||
| const reportIDWithUrl = isChatThread(topMostReport) ? findUrlInReportOrAncestorAttachments(topMostReport, url) : undefined; | ||
|
|
||
| // - if it is a chat thread, use chat thread ID or any ascentor ID since the video could have originally been sent on report many levels up |
There was a problem hiding this comment.
| // - if it is a chat thread, use chat thread ID or any ascentor ID since the video could have originally been sent on report many levels up | |
| // - if it is a chat thread, use chat thread ID or any ancestor ID since the video could have originally been sent on report many levels up |
|
|
||
| // Used for /attachment route | ||
| const topMostReport = getReportOrDraftReport(Navigation.getTopmostReportId()); | ||
| const reportIDFromUrlParams = new URLSearchParams(Navigation.getActiveRoute()).get('reportID') ?? undefined; |
There was a problem hiding this comment.
I think all of these should have URL uppercase in name based on our style guides
| const reportIDFromUrlParams = new URLSearchParams(Navigation.getActiveRoute()).get('reportID') ?? undefined; | |
| const reportIDFromURLParams = new URLSearchParams(Navigation.getActiveRoute()).get('reportID') ?? undefined; |
| return !!route && !!route.params && route.name === SCREENS.SEARCH.MONEY_REQUEST_REPORT && 'reportID' in route.params; | ||
| } | ||
|
|
||
| function findUrlInReportOrAncestorAttachments(currentReport: OnyxEntry<Report>, url: string | null): string | undefined { |
There was a problem hiding this comment.
| function findUrlInReportOrAncestorAttachments(currentReport: OnyxEntry<Report>, url: string | null): string | undefined { | |
| function findURLInReportOrAncestorAttachments(currentReport: OnyxEntry<Report>, url: string | null): string | undefined { |
| return !!route && !!route.params && route.name === SCREENS.SEARCH.MONEY_REQUEST_REPORT && 'reportID' in route.params; | ||
| } | ||
|
|
||
| function findUrlInReportOrAncestorAttachments(currentReport: OnyxEntry<Report>, url: string | null): string | undefined { |
There was a problem hiding this comment.
NAB: I think adding more docs to this method would be helpful.
|
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
|
🚀 Deployed to staging by https://github.com/mountiny in version: 9.1.24-2 🚀
|
|
🚀 Deployed to production by https://github.com/jasperhuangg in version: 9.1.24-10 🚀
|
|
🚀 Deployed to production by https://github.com/jasperhuangg in version: 9.1.24-10 🚀
|
Explanation of Change
Related to #59459
Currently,
VideoPlayerPreviewusesusePlaybackContextto getcurrentlyPlayingURLandcurrentlyPlayingURLReportIDfrom thePlaybackContextProvider.Inside the context provider, there are actually 2 states related to the video report ID -
currentlyPlayingURLReportIDandcurrentReportID.The
currentReportIDis modified when the navigation within theNavigationRootchanges (it is equal to topmost report), and thecurrentPlayingURLReportIDis modified when the video is clicked to play.The
currentlyPlayingURLReportIDis a copy of thecurrentReportIDonly when the video is actually playing.The
VideoPlayerPreviewcompares the video url and report ID associated with the video to context data to check if the video should be played via useEffect so that it stops when the user navigates to another route.It also has
isThumbnailfor optimization purposes, so it will display a thumbnail if a video shouldn't be played.This is a clever idea, but it creates problems that this PR solves.
123, and we enter the thread of that report (by replying to the video), then the topmost report is no longer a123(because we are in a thread), but the video report ID is still123. Other videos posted within this thread will use a topmost ID (thread ID) except for the first one./attachmentand reportID is in route params.What this PR does is:
/attachmentroute, it is also included in the conditionalfindUrlInReportOrAncestorAttachmentsupdateCurrentPlayingReportIDmethod.updateCurrentlyPlayingURL, which actually also setscurrentlyPlayingURLReportID, it will use the first valid reportID from the array of:Fixed Issues
$ #57731
$ #58833
PROPOSAL: N/A
Tests
[Chat thread]
[Expense report view]
Offline tests
N/A
QA Steps
Same as tests
PR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectiontoggleReportand notonIconClick)src/languages/*files and using the translation methodSTYLE.md) were followedAvatar, I verified the components usingAvatarare working as expected)StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))Avataris modified, I verified thatAvataris working as expected in all cases)Designlabel and/or tagged@Expensify/designso the design team can review the changes.ScrollViewcomponent to make it scrollable when more elements are added to the page.mainbranch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTeststeps.Screenshots/Videos
Android: Native
Android.mp4
Android: mWeb Chrome
iOS: Native
iOS.mp4
iOS: mWeb Safari
MacOS: Chrome / Safari
Web.mov
MacOS: Desktop