-
Notifications
You must be signed in to change notification settings - Fork 3.2k
[Better Expense Report View] Fix video player in expense report view & chat thread #59430
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// - 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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,
VideoPlayerPreview
usesusePlaybackContext
to getcurrentlyPlayingURL
andcurrentlyPlayingURLReportID
from thePlaybackContextProvider
.Inside the context provider, there are actually 2 states related to the video report ID -
currentlyPlayingURLReportID
andcurrentReportID
.The
currentReportID
is modified when the navigation within theNavigationRoot
changes (it is equal to topmost report), and thecurrentPlayingURLReportID
is modified when the video is clicked to play.The
currentlyPlayingURLReportID
is a copy of thecurrentReportID
only when the video is actually playing.The
VideoPlayerPreview
compares 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
isThumbnail
for 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./attachment
and reportID is in route params.What this PR does is:
/attachment
route, it is also included in the conditionalfindUrlInReportOrAncestorAttachments
updateCurrentPlayingReportID
method.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 Issues
section aboveTests
sectionOffline steps
sectionQA steps
sectiontoggleReport
and notonIconClick
)src/languages/*
files and using the translation methodSTYLE.md
) were followedAvatar
, I verified the components usingAvatar
are working as expected)StyleUtils.getBackgroundAndBorderStyle(theme.componentBG)
)Avatar
is modified, I verified thatAvatar
is working as expected in all cases)Design
label and/or tagged@Expensify/design
so the design team can review the changes.ScrollView
component to make it scrollable when more elements are added to the page.main
branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTest
steps.Screenshots/Videos
Android: Native
Android.mp4
Android: mWeb Chrome
iOS: Native
iOS.mp4
iOS: mWeb Safari
MacOS: Chrome / Safari
Web.mov
MacOS: Desktop