Skip to content

Commit

Permalink
Merge pull request #34590 from Expensify/cristi_send-app-source-when-…
Browse files Browse the repository at this point in the history
…chatting-with-concierge

Send app source when chatting with Concierge, after redirection from OldDot
  • Loading branch information
marcochavezf authored Jan 16, 2024
2 parents d9ee78d + 4524a3e commit 0710726
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/libs/actions/Report.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import {format as timezoneFormat, utcToZonedTime} from 'date-fns-tz';
import ExpensiMark from 'expensify-common/lib/ExpensiMark';
import Str from 'expensify-common/lib/str';
import isEmpty from 'lodash/isEmpty';
import {DeviceEventEmitter, InteractionManager} from 'react-native';
import {DeviceEventEmitter, InteractionManager, Linking} from 'react-native';
import type {OnyxCollection, OnyxEntry, OnyxUpdate} from 'react-native-onyx';
import Onyx from 'react-native-onyx';
import type {NullishDeep} from 'react-native-onyx/lib/types';
Expand Down Expand Up @@ -127,6 +127,14 @@ const allReports: OnyxCollection<Report> = {};
let conciergeChatReportID: string | undefined;
const typingWatchTimers: Record<string, NodeJS.Timeout> = {};

let reportIDDeeplinkedFromOldDot: string | undefined;
Linking.getInitialURL().then((url) => {
const params = new URLSearchParams(url ?? '');
const exitToRoute = params.get('exitTo') ?? '';
const {reportID} = ReportUtils.parseReportRouteParams(exitToRoute);
reportIDDeeplinkedFromOldDot = reportID;
});

/** Get the private pusher channel name for a Report. */
function getReportChannelName(reportID: string): string {
return `${CONST.PUSHER.PRIVATE_REPORT_CHANNEL_PREFIX}${reportID}${CONFIG.PUSHER.SUFFIX}`;
Expand Down Expand Up @@ -343,6 +351,7 @@ function addActions(reportID: string, text = '', file?: File) {
timezone?: string;
shouldAllowActionableMentionWhispers?: boolean;
clientCreatedTime?: string;
isOldDotConciergeChat?: boolean;
};

const parameters: AddCommentOrAttachementParameters = {
Expand All @@ -355,6 +364,10 @@ function addActions(reportID: string, text = '', file?: File) {
clientCreatedTime: file ? attachmentAction?.created : reportCommentAction?.created,
};

if (reportIDDeeplinkedFromOldDot === reportID && report?.participantAccountIDs?.length === 1 && Number(report.participantAccountIDs?.[0]) === CONST.ACCOUNT_ID.CONCIERGE) {
parameters.isOldDotConciergeChat = true;
}

const optimisticData: OnyxUpdate[] = [
{
onyxMethod: Onyx.METHOD.MERGE,
Expand Down

0 comments on commit 0710726

Please sign in to comment.