Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
34 changes: 11 additions & 23 deletions src/pages/inbox/report/ReportActionCompose/ComposerBox.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import React from 'react';
import {View} from 'react-native';
import OfflineWithFeedback from '@components/OfflineWithFeedback';
import useOnyx from '@hooks/useOnyx';
import useThemeStyles from '@hooks/useThemeStyles';
import {getReportOfflinePendingActionAndErrors} from '@libs/ReportUtils';
import ONYXKEYS from '@src/ONYXKEYS';
import {useComposerMeta, useComposerSendState, useComposerState} from './ComposerContext';

Expand All @@ -18,31 +16,21 @@ function ComposerBox({reportID, children}: ComposerBoxProps) {
const {exceededMaxLength, isBlockedFromConcierge} = useComposerSendState();
const {containerRef} = useComposerMeta();
const [isComposerFullSize = false] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_IS_COMPOSER_FULL_SIZE}${reportID}`);
const [report] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${reportID}`);

const {reportPendingAction: pendingAction} = getReportOfflinePendingActionAndErrors(report);
const shouldUseFocusedColor = !isBlockedFromConcierge && isFocused;

return (
<OfflineWithFeedback
shouldDisableOpacity
pendingAction={pendingAction}
style={isComposerFullSize ? styles.chatItemFullComposeRow : {}}
contentContainerStyle={isComposerFullSize ? styles.flex1 : {}}
<View
ref={containerRef}
style={[
shouldUseFocusedColor ? styles.chatItemComposeBoxFocusedColor : styles.chatItemComposeBoxColor,
styles.flexRow,
styles.chatItemComposeBox,
isComposerFullSize && styles.chatItemFullComposeBox,
!!exceededMaxLength && styles.borderColorDanger,
]}
>
<View
ref={containerRef}
style={[
shouldUseFocusedColor ? styles.chatItemComposeBoxFocusedColor : styles.chatItemComposeBoxColor,
styles.flexRow,
styles.chatItemComposeBox,
isComposerFullSize && styles.chatItemFullComposeBox,
!!exceededMaxLength && styles.borderColorDanger,
]}
>
{children}
</View>
</OfflineWithFeedback>
{children}
</View>
);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import React from 'react';
import {View} from 'react-native';
import OfflineIndicator from '@components/OfflineIndicator';
import OfflineWithFeedback from '@components/OfflineWithFeedback';
import useOnyx from '@hooks/useOnyx';
import useResponsiveLayout from '@hooks/useResponsiveLayout';
import useThemeStyles from '@hooks/useThemeStyles';
import {getReportOfflinePendingActionAndErrors} from '@libs/ReportUtils';
import ONYXKEYS from '@src/ONYXKEYS';
import AgentZeroAwareTypingIndicator from './AgentZeroAwareTypingIndicator';
import ComposerActionMenu from './ComposerActionMenu';
Expand All @@ -29,6 +31,7 @@ function ReportActionComposeInner({reportID}: ReportActionComposeProps) {
const {shouldUseNarrowLayout} = useResponsiveLayout();
const [report] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT}${reportID}`);
const [isComposerFullSize = false] = useOnyx(`${ONYXKEYS.COLLECTION.REPORT_IS_COMPOSER_FULL_SIZE}${reportID}`);
const {reportPendingAction: pendingAction} = getReportOfflinePendingActionAndErrors(report);

if (!report) {
return null;
Expand All @@ -38,19 +41,26 @@ function ReportActionComposeInner({reportID}: ReportActionComposeProps) {
<View style={[isComposerFullSize && styles.chatItemFullComposeRow]}>
<ComposerLocalTime reportID={reportID} />
<View style={isComposerFullSize ? styles.flex1 : {}}>
<ComposerDropZone reportID={reportID}>
<ComposerBox reportID={reportID}>
<ComposerActionMenu reportID={reportID} />
<ComposerInput reportID={reportID} />
<ComposerEmojiPicker reportID={reportID} />
<ComposerSendButton />
</ComposerBox>
</ComposerDropZone>
<ComposerFooter>
{!shouldUseNarrowLayout && <OfflineIndicator containerStyles={[styles.chatItemComposeSecondaryRow]} />}
<AgentZeroAwareTypingIndicator reportID={reportID} />
<ComposerExceededLength />
</ComposerFooter>
<OfflineWithFeedback
shouldDisableOpacity
pendingAction={pendingAction}
style={isComposerFullSize ? styles.chatItemFullComposeRow : {}}
contentContainerStyle={isComposerFullSize ? styles.flex1 : {}}
>
<ComposerDropZone reportID={reportID}>
<ComposerBox reportID={reportID}>
<ComposerActionMenu reportID={reportID} />
<ComposerInput reportID={reportID} />
<ComposerEmojiPicker reportID={reportID} />
<ComposerSendButton />
</ComposerBox>
</ComposerDropZone>
<ComposerFooter>
{!shouldUseNarrowLayout && <OfflineIndicator containerStyles={[styles.chatItemComposeSecondaryRow]} />}
<AgentZeroAwareTypingIndicator reportID={reportID} />
<ComposerExceededLength />
</ComposerFooter>
</OfflineWithFeedback>
<ComposerImportedState />
</View>
</View>
Expand Down
Loading