Skip to content
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

[CP Staging] Remove quick action report when leaving group chat #40511

Merged
merged 3 commits into from
Apr 19, 2024
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions src/libs/actions/Report.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ import type {
PersonalDetails,
PersonalDetailsList,
PolicyReportField,
QuickAction,
RecentlyUsedReportFields,
ReportActionReactions,
ReportMetadata,
Expand Down Expand Up @@ -219,6 +220,12 @@ Onyx.connect({
callback: (val) => (allRecentlyUsedReportFields = val),
});

let quickAction: OnyxEntry<QuickAction> = {};
Onyx.connect({
key: ONYXKEYS.NVP_QUICK_ACTION_GLOBAL_CREATE,
callback: (val) => (quickAction = val),
});

function clearGroupChat() {
Onyx.set(ONYXKEYS.NEW_GROUP_CHAT_DRAFT, null);
}
Expand Down Expand Up @@ -2449,6 +2456,15 @@ function leaveGroupChat(reportID: string) {
value: null,
},
];
// Clean up any quick actions for the report we're leaving from
if (quickAction?.chatReportID?.toString() === reportID) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Even though quickAction.chatReportID is defined as a string, I've noticed that it was actually stored as an int in Onyx. I'm not sure why, since every flow that I traced had it as a string before saving it to Onyx.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's strange. For me, chatReportID is stored as a string in onyx. I also do not see usage of int in any flow. Further, I also tried relogin and tried various flows and it still stores as string. Looks good to me though.

optimisticData.push({
onyxMethod: Onyx.METHOD.SET,
key: ONYXKEYS.NVP_QUICK_ACTION_GLOBAL_CREATE,
value: null,
})
}

navigateToMostRecentReport(report);
API.write(WRITE_COMMANDS.LEAVE_GROUP_CHAT, {reportID}, {optimisticData});
}
Expand Down
Loading