Skip to content

Commit ce12189

Browse files
authored
Merge pull request Expensify#63108 from Expensify/jasper-agentZeroProcessingRequestIndicator
[NO QA] Display the `AgentZeroProcessingRequestIndicator`
2 parents 188979a + b314695 commit ce12189

5 files changed

Lines changed: 48 additions & 0 deletions

File tree

src/libs/DebugUtils.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -582,6 +582,8 @@ function validateReportDraftProperty(key: keyof Report | keyof ReportNameValuePa
582582
eventURI: 'string',
583583
inserted: 'string',
584584
});
585+
case 'agentZeroProcessingRequestIndicator':
586+
return validateString(value);
585587
case 'pendingAction':
586588
return validateConstantEnum(value, CONST.RED_BRICK_ROAD_PENDING_ACTION);
587589
case 'pendingFields':
@@ -648,6 +650,7 @@ function validateReportDraftProperty(key: keyof Report | keyof ReportNameValuePa
648650
exportFailedTime: CONST.RED_BRICK_ROAD_PENDING_ACTION,
649651
calendlySchedule: CONST.RED_BRICK_ROAD_PENDING_ACTION,
650652
calendlyCalls: CONST.RED_BRICK_ROAD_PENDING_ACTION,
653+
agentZeroProcessingRequestIndicator: CONST.RED_BRICK_ROAD_PENDING_ACTION,
651654
});
652655
}
653656
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import React, {memo, useMemo} from 'react';
2+
import {useOnyx} from 'react-native-onyx';
3+
import Text from '@components/Text';
4+
import useNetwork from '@hooks/useNetwork';
5+
import useThemeStyles from '@hooks/useThemeStyles';
6+
import ONYXKEYS from '@src/ONYXKEYS';
7+
8+
type AgentZeroProcessingRequestIndicatorProps = {
9+
reportID: string;
10+
};
11+
12+
function AgentZeroProcessingRequestIndicator({reportID}: AgentZeroProcessingRequestIndicatorProps) {
13+
const styles = useThemeStyles();
14+
const {isOffline} = useNetwork();
15+
const [reportNameValuePairs] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_NAME_VALUE_PAIRS}${reportID}`, {canBeMissing: true});
16+
const [userTypingStatuses] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_USER_IS_TYPING}${reportID}`, {canBeMissing: true});
17+
18+
// Check if anyone is currently typing
19+
const usersTyping = useMemo(() => Object.keys(userTypingStatuses ?? {}).filter((loginOrAccountID) => userTypingStatuses?.[loginOrAccountID]), [userTypingStatuses]);
20+
const isAnyoneTyping = usersTyping.length > 0;
21+
22+
// Don't show if offline, if anyone is typing (typing indicator takes precedence), or if the indicator doesn't exist
23+
if (isOffline || isAnyoneTyping || !reportNameValuePairs?.agentZeroProcessingRequestIndicator) {
24+
return null;
25+
}
26+
27+
return (
28+
<Text
29+
style={[styles.chatItemComposeSecondaryRowSubText, styles.chatItemComposeSecondaryRowOffset]}
30+
numberOfLines={1}
31+
>
32+
{reportNameValuePairs.agentZeroProcessingRequestIndicator}
33+
</Text>
34+
);
35+
}
36+
37+
AgentZeroProcessingRequestIndicator.displayName = 'AgentZeroProcessingRequestIndicator';
38+
39+
export default memo(AgentZeroProcessingRequestIndicator);

src/pages/home/report/ReportActionCompose/ReportActionCompose.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ import {
5656
import {getTransactionID, hasReceipt as hasReceiptTransactionUtils} from '@libs/TransactionUtils';
5757
import willBlurTextInputOnTapOutsideFunc from '@libs/willBlurTextInputOnTapOutside';
5858
import Navigation from '@navigation/Navigation';
59+
import AgentZeroProcessingRequestIndicator from '@pages/home/report/AgentZeroProcessingRequestIndicator';
5960
import ParticipantLocalTime from '@pages/home/report/ParticipantLocalTime';
6061
import ReportDropUI from '@pages/home/report/ReportDropUI';
6162
import ReportTypingIndicator from '@pages/home/report/ReportTypingIndicator';
@@ -710,6 +711,7 @@ function ReportActionCompose({
710711
>
711712
{!shouldUseNarrowLayout && <OfflineIndicator containerStyles={[styles.chatItemComposeSecondaryRow]} />}
712713
<ReportTypingIndicator reportID={reportID} />
714+
<AgentZeroProcessingRequestIndicator reportID={reportID} />
713715
{!!exceededMaxLength && (
714716
<ExceededCommentLength
715717
maxCommentLength={exceededMaxLength}

src/types/onyx/ReportNameValuePairs.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,9 @@ type ReportNameValuePairs = OnyxCommon.OnyxValueWithOfflineFeedback<{
7575

7676
/** The time the report export failed */
7777
exportFailedTime?: string;
78+
79+
/** Agent Zero processing request indicator message */
80+
agentZeroProcessingRequestIndicator?: string;
7881
}>;
7982

8083
/** Collection of reportNameValuePairs, indexed by reportNameValuePairs_{reportID} */

src/types/utils/whitelistedReportKeys.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ type WhitelistedReport = OnyxCommon.OnyxValueWithOfflineFeedback<
6363
};
6464
private_isArchived: unknown;
6565
welcomeMessage: unknown;
66+
agentZeroProcessingRequestIndicator: unknown;
6667
},
6768
PolicyReportField['fieldID']
6869
>;

0 commit comments

Comments
 (0)