From e5062fcbec8cdb38132a33eca604ab6fff03451b Mon Sep 17 00:00:00 2001 From: Carlos Martins Date: Thu, 18 Apr 2024 16:06:34 -0600 Subject: [PATCH 1/3] clean up quick action if it belongs to a left report --- src/libs/actions/Report.ts | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/libs/actions/Report.ts b/src/libs/actions/Report.ts index 7bcb82861769..d93dcbeb96bb 100644 --- a/src/libs/actions/Report.ts +++ b/src/libs/actions/Report.ts @@ -82,6 +82,7 @@ import type { PersonalDetails, PersonalDetailsList, PolicyReportField, + QuickAction, RecentlyUsedReportFields, ReportActionReactions, ReportMetadata, @@ -219,6 +220,12 @@ Onyx.connect({ callback: (val) => (allRecentlyUsedReportFields = val), }); +let quickAction: OnyxEntry = {}; +Onyx.connect({ + key: ONYXKEYS.NVP_QUICK_ACTION_GLOBAL_CREATE, + callback: (val) => (quickAction = val), +}); + function clearGroupChat() { Onyx.set(ONYXKEYS.NEW_GROUP_CHAT_DRAFT, null); } @@ -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 == reportID) { + 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}); } From d232d703bf07bda70bd217bb8f845425ee946b48 Mon Sep 17 00:00:00 2001 From: Carlos Martins Date: Thu, 18 Apr 2024 16:14:35 -0600 Subject: [PATCH 2/3] convert to string --- src/libs/actions/Report.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/actions/Report.ts b/src/libs/actions/Report.ts index d93dcbeb96bb..cdc383394462 100644 --- a/src/libs/actions/Report.ts +++ b/src/libs/actions/Report.ts @@ -2457,7 +2457,7 @@ function leaveGroupChat(reportID: string) { }, ]; // Clean up any quick actions for the report we're leaving from - if (quickAction?.chatReportID == reportID) { + if (quickAction?.chatReportID?.toString() === reportID) { optimisticData.push({ onyxMethod: Onyx.METHOD.SET, key: ONYXKEYS.NVP_QUICK_ACTION_GLOBAL_CREATE, From ef38282a8c81b3cf8b06c6caf15d2dc722e8144a Mon Sep 17 00:00:00 2001 From: Carlos Martins Date: Thu, 18 Apr 2024 16:21:04 -0600 Subject: [PATCH 3/3] fix lint --- src/libs/actions/Report.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libs/actions/Report.ts b/src/libs/actions/Report.ts index cdc383394462..bc816cf6952d 100644 --- a/src/libs/actions/Report.ts +++ b/src/libs/actions/Report.ts @@ -2462,7 +2462,7 @@ function leaveGroupChat(reportID: string) { onyxMethod: Onyx.METHOD.SET, key: ONYXKEYS.NVP_QUICK_ACTION_GLOBAL_CREATE, value: null, - }) + }); } navigateToMostRecentReport(report);