-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
Fixes "Not here" page briefly showing when last member leaves group chat. #50846
Changes from 5 commits
480c4b4
0e77f38
63b49be
6eb346a
1f52c29
0851b74
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 |
---|---|---|
|
@@ -2759,11 +2759,22 @@ function leaveGroupChat(reportID: string) { | |
return; | ||
} | ||
|
||
// Use merge instead of set to avoid deleting the report too quickly, which could cause a brief "not found" page to appear. | ||
// The remaining parts of the report object will be removed after the API call is successful. | ||
const optimisticData: OnyxUpdate[] = [ | ||
{ | ||
onyxMethod: Onyx.METHOD.SET, | ||
onyxMethod: Onyx.METHOD.MERGE, | ||
key: `${ONYXKEYS.COLLECTION.REPORT}${reportID}`, | ||
value: null, | ||
value: { | ||
reportID: null, | ||
stateNum: CONST.REPORT.STATE_NUM.APPROVED, | ||
statusNum: CONST.REPORT.STATUS_NUM.CLOSED, | ||
participants: { | ||
[currentUserAccountID]: { | ||
notificationPreference: CONST.REPORT.NOTIFICATION_PREFERENCE.HIDDEN, | ||
}, | ||
}, | ||
}, | ||
}, | ||
]; | ||
// Clean up any quick actions for the report we're leaving from | ||
|
@@ -2775,8 +2786,27 @@ function leaveGroupChat(reportID: string) { | |
}); | ||
} | ||
|
||
const successData: OnyxUpdate[] = [ | ||
{ | ||
onyxMethod: Onyx.METHOD.MERGE, | ||
key: `${ONYXKEYS.COLLECTION.REPORT}${reportID}`, | ||
value: Object.keys(report).reduce<Record<string, null>>((acc, key) => { | ||
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. This block led to the following issue: which was fixed by setting value to |
||
acc[key] = null; | ||
return acc; | ||
}, {}), | ||
}, | ||
]; | ||
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. Does the Success response delete this report from API? 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. Based on the network inspect in this video -- yes 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. Then do we need this? 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. 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. @parasharrajat I think we don't really need that, but do you think applying https updates can be paused for some reason? 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. @parasharrajat I'm afraid remove request from the server will be pending, I think we'll still need this successData https://github.com/Expensify/App/blob/main/src%2Flibs%2Factions%2FOnyxUpdates.ts#L30 |
||
|
||
const failureData: OnyxUpdate[] = [ | ||
{ | ||
onyxMethod: Onyx.METHOD.MERGE, | ||
key: `${ONYXKEYS.COLLECTION.REPORT}${reportID}`, | ||
value: report, | ||
}, | ||
]; | ||
|
||
navigateToMostRecentReport(report); | ||
API.write(WRITE_COMMANDS.LEAVE_GROUP_CHAT, {reportID}, {optimisticData}); | ||
API.write(WRITE_COMMANDS.LEAVE_GROUP_CHAT, {reportID}, {optimisticData, successData, failureData}); | ||
} | ||
|
||
/** Leave a report by setting the state to submitted and closed */ | ||
|
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 we need to pass these?
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.
@parasharrajat I think some places use that to determine archive mode. Seems we'll need that especially when the user offline