-
Notifications
You must be signed in to change notification settings - Fork 3.2k
[CP Staging] Fix blinking old type of report #62562
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -100,7 +100,7 @@ function MoneyRequestReportView({report, policy, reportMetadata, shouldDisplayRe | |
|
||
const transactionThreadReportID = getOneTransactionThreadReportID(reportID, reportActions ?? [], isOffline); | ||
|
||
const [transactions = undefined] = useOnyx(ONYXKEYS.COLLECTION.TRANSACTION, { | ||
const [transactions] = useOnyx(ONYXKEYS.COLLECTION.TRANSACTION, { | ||
selector: (allTransactions: OnyxCollection<OnyxTypes.Transaction>) => selectAllTransactionsForReport(allTransactions, reportID, reportActions), | ||
canBeMissing: true, | ||
}); | ||
|
@@ -123,8 +123,14 @@ function MoneyRequestReportView({report, policy, reportMetadata, shouldDisplayRe | |
// If true we will use standard `ReportActionsView` to display report data and a special header, anything else is handled via `MoneyRequestReportActionsList` | ||
const isTransactionThreadView = isReportTransactionThread(report); | ||
|
||
const isEmptyTransactionReport = transactions && transactionThreadReportID === undefined && !isLoadingInitialReportActions; | ||
const shouldDisplayMoneyRequestActionsList = !!isEmptyTransactionReport && shouldDisplayReportTableView(report, transactions); | ||
// Prevent flash by ensuring transaction data is fully loaded before deciding which view to render | ||
// We need to wait for both the selector to finish AND ensure we're not in a loading state where transactions could still populate | ||
const isTransactionDataReady = transactions !== undefined; | ||
const isStillLoadingData = !!isLoadingInitialReportActions || !!reportMetadata?.isLoadingOlderReportActions || !!reportMetadata?.isLoadingNewerReportActions; | ||
const shouldWaitForData = (!isTransactionDataReady || (isStillLoadingData && transactions?.length === 0)) && !isTransactionThreadView; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why do we check for There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Initially, when transactions come from Onyx, they are an empty array - not undefined. So the check for transactions?.length === 0 helps us distinguish between "data is ready but empty" vs "data is still loading". |
||
|
||
const isEmptyTransactionReport = transactions && transactions.length === 0 && transactionThreadReportID === undefined; | ||
const shouldDisplayMoneyRequestActionsList = !!isEmptyTransactionReport || shouldDisplayReportTableView(report, transactions ?? []); | ||
|
||
const reportHeaderView = useMemo( | ||
() => | ||
|
@@ -160,7 +166,7 @@ function MoneyRequestReportView({report, policy, reportMetadata, shouldDisplayRe | |
[activeWorkspaceID, backToRoute, isTransactionThreadView, parentReportAction, policy, report, reportActions, transactionThreadReportID], | ||
); | ||
|
||
if (!!(isLoadingInitialReportActions && reportActions.length === 0 && !isOffline) || !transactions) { | ||
if (!!(isLoadingInitialReportActions && reportActions.length === 0 && !isOffline) || shouldWaitForData) { | ||
return <InitialLoadingSkeleton styles={styles} />; | ||
} | ||
|
||
|
@@ -214,6 +220,7 @@ function MoneyRequestReportView({report, policy, reportMetadata, shouldDisplayRe | |
reportActions={reportActions} | ||
hasOlderActions={hasOlderActions} | ||
hasNewerActions={hasNewerActions} | ||
isLoadingInitialReportActions={isLoadingInitialReportActions} | ||
/> | ||
) : ( | ||
<ReportActionsView | ||
|
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.
Why do we check for
reportMetadata?.isLoadingOlderReportActions
andreportMetadata?.isLoadingNewerReportActions
?I've found one case(it was really hard to reproduce it 😄 ) when:
loadNewerChats
fromMoneyRequestReportActionsList
fires and makesreportMetadata?.isLoadingNewerReportActions
trueInitialLoadingSkeleton
flashes for a moment