Skip to content

Commit 7d8d521

Browse files
committed
Send message to admins chat if it's the one in the side panel on web
1 parent ae1ca81 commit 7d8d521

1 file changed

Lines changed: 9 additions & 6 deletions

File tree

src/components/Search/SearchRouter/useAskConcierge.tsx

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,30 +2,33 @@ import useCurrentUserPersonalDetails from '@hooks/useCurrentUserPersonalDetails'
22
import useDelegateAccountID from '@hooks/useDelegateAccountID';
33
import useOnyx from '@hooks/useOnyx';
44
import useOpenConciergeAnywhere from '@hooks/useOpenConciergeAnywhere';
5+
import useSidePanelReportID from '@hooks/useSidePanelReportID';
56
import getNonEmptyStringOnyxID from '@libs/getNonEmptyStringOnyxID';
67
import {addComment} from '@userActions/Report';
78
import CONST from '@src/CONST';
89
import ONYXKEYS from '@src/ONYXKEYS';
910

1011
/**
11-
* Returns a callback that opens Concierge (side panel on web, chat on native)
12+
* Returns a callback that opens the side panel (or Concierge chat on native)
1213
* and sends the provided search query as a message.
1314
*/
1415
function useAskConcierge() {
16+
const sidePanelReportID = useSidePanelReportID();
1517
const [conciergeReportID] = useOnyx(ONYXKEYS.CONCIERGE_REPORT_ID);
16-
const [conciergeReport] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${getNonEmptyStringOnyxID(conciergeReportID)}`);
17-
const {timezone, accountID: currentUserAccountID} = useCurrentUserPersonalDetails();
1818
const {openConciergeAnywhere, isInSidePanel} = useOpenConciergeAnywhere();
19+
const targetReportID = (isInSidePanel ? sidePanelReportID : undefined) ?? conciergeReportID;
20+
const [targetReport] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${getNonEmptyStringOnyxID(targetReportID)}`);
21+
const {timezone, accountID: currentUserAccountID} = useCurrentUserPersonalDetails();
1922
const delegateAccountID = useDelegateAccountID();
2023

2124
return (searchQuery: string) => {
2225
openConciergeAnywhere();
23-
if (!conciergeReport || !conciergeReportID) {
26+
if (!targetReport || !targetReportID) {
2427
return;
2528
}
2629
addComment({
27-
report: conciergeReport,
28-
notifyReportID: conciergeReportID,
30+
report: targetReport,
31+
notifyReportID: targetReportID,
2932
ancestors: [],
3033
text: searchQuery,
3134
timezoneParam: timezone ?? CONST.DEFAULT_TIME_ZONE,

0 commit comments

Comments
 (0)