-
Notifications
You must be signed in to change notification settings - Fork 3k
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
fix: Skeleton is displayed when create offline Room in focus mode and switch #54180
base: main
Are you sure you want to change the base?
Conversation
Reviewer Checklist
Screenshots/VideosAndroid: Nativeandroid-app-2024-12-16_14.57.08.mp4Android: mWeb Chromeandroid-chrome-2024-12-16_14.59.08.mp4iOS: Nativeios-app-2024-12-16_15.05.49.mp4iOS: mWeb Safariios-safari-2024-12-16_15.10.50.mp4MacOS: Chrome / Safaridesktop-chrome-2024-12-16_14.51.36.mp4MacOS: Desktopdesktop-app-2024-12-16_14.54.18.mp4 |
src/libs/actions/Report.ts
Outdated
@@ -2386,6 +2393,13 @@ function addPolicyReport(policyReport: ReportUtils.OptimisticChatReport) { | |||
key: ONYXKEYS.FORMS.NEW_ROOM_FORM, | |||
value: {isLoading: false}, | |||
}, | |||
{ | |||
onyxMethod: Onyx.METHOD.MERGE, |
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.
This is duplicate code of the above section. But I think we do want it in the failureData
as isOptimisticReport
should always clear.
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 added the isOptimisticReport: false
to failureData
.
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.
Do you see that we already have this code above though?
App/src/libs/actions/Report.ts
Lines 2376 to 2380 in 83267e2
onyxMethod: Onyx.METHOD.MERGE, | |
key: `${ONYXKEYS.COLLECTION.REPORT_METADATA}${policyReport.reportID}`, | |
value: { | |
isOptimisticReport: false, | |
}, |
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.
src/pages/home/ReportScreen.tsx
Outdated
@@ -384,7 +384,7 @@ function ReportScreen({route, currentReportID = '', navigation}: ReportScreenPro | |||
!isCurrentReportLoadedFromOnyx || | |||
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing | |||
(deleteTransactionNavigateBackUrl && ReportUtils.getReportIDFromLink(deleteTransactionNavigateBackUrl) === report?.reportID) || | |||
isLoading; | |||
((!ReportUtils.isUserCreatedPolicyRoom(report) || !reportMetadata.isOptimisticReport) && isLoading); |
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.
Hmm now that I think about it this feels a bit hacky. Is there any reason to specifically apply this to policy rooms?
I've also noticed whilst testing that isLoadingApp
gets set to true only when the mode is switched to Most recent
(not to #focus
), which makes me think that we may have actually missed the true RCA here. I think isLoadingApp
is either being incorrectly set when the focus mode is switched, or this is an unexpected side-effect of it.
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.
A similar behaviour happens on any existing report, where if you switch specifically from #focus
to Most recent
, only the most recent message loads, the rest are in a loading state.
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.
Hmm now that I think about it this feels a bit hacky. Is there any reason to specifically apply this to policy rooms?
- I just want to ensure this change doesn’t unintentionally affect other report types I might not have context on. It’s important to verify these also work correctly with the new change.
I've also noticed whilst testing that isLoadingApp gets set to true only when the mode is switched to Most recent (not to #focus), which makes me think that we may have actually missed the true RCA here. I think isLoadingApp is either being incorrectly set when the focus mode is switched, or this is an unexpected side-effect of it.
- When switching from focus mode to default mode, we call openApp():
Lines 75 to 78 in d86024e
// When someone switches their priority mode we need to fetch all their chats because only #focus mode works with a subset of a user's chats. This is only possible via the OpenApp command. if (nextPriorityMode === CONST.PRIORITY_MODE.DEFAULT && priorityMode === CONST.PRIORITY_MODE.GSD) { // eslint-disable-next-line @typescript-eslint/no-use-before-define openApp();
As a result, isLoadingApp gets set to true.
A similar behavior happens on any existing report, where if you switch specifically from #focus to Most recent, only the most recent message loads, the rest are in a loading state.
- I see your point. However, for existing reports, we show the loading indicator because we don’t know “how many actions are missing” when switching from focus mode to default mode. In the case of an optimistic report, though, we can confidently determine that “no fetch is needed,” as explained here:
App/src/libs/shouldFetchReport.ts
Line 7 in d86024e
// If the report is optimistic, there's no need to fetch it. The original action should create it. |
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 just want to ensure this change doesn’t unintentionally affect other report types I might not have context on. It’s important to verify these also work correctly with the new change.
Makes sense, limiting the scope can reduce the chance for regressions. Are we okay to just focus on rooms here @lakchote, or do you think we should fix other reports (e.g. group chats)?
However, for existing reports, we show the loading indicator because we don’t know “how many actions are missing”
Okay, just gonna check on Slack regarding the expected behaviour there to make sure.
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'd say we need to fix the whole issue as a whole and fix this for other reports.
If this introduces potential side effects/regressions, then we'll need to fix it and that would indicate the RCA of the solution here wasn't the correct one. I'd prefer to have solved the root cause and not a possibly hack that works for certain report types.
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.
Okay gotcha - let's do it for all report types, then - unless you disagree @truph01.
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.
Tests well and LGTM (we can ignore the lint errors since they're not parts of the code we've touched). We've limited scope here to affect Rooms only (see here)
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.
LGTM! Confirmed that it works with other chat types, e.g. group chat.
All yours @lakchote 🙏 |
Explanation of Change
Fixed Issues
$ #53660
PROPOSAL: #53660 (comment)
Tests
Offline tests
QA Steps
// TODO: These must be filled out, or the issue title must include "[No QA]."
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
output.mp4
Android: mWeb Chrome
Screen.Recording.2024-12-16.at.15.26.56.mov
iOS: Native
Screen.Recording.2024-12-16.at.15.30.45.mov
iOS: mWeb Safari
Screen.Recording.2024-12-16.at.15.32.31.mov
MacOS: Chrome / Safari
Screen.Recording.2024-12-16.at.15.17.27.mov
MacOS: Desktop
Screen.Recording.2024-12-16.at.15.34.29.mov