Skip to content
Merged
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
24 changes: 20 additions & 4 deletions src/pages/home/report/ReportActionItemMessage.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,29 @@ import React from 'react';
import {View} from 'react-native';
import PropTypes from 'prop-types';
import _ from 'underscore';
import {withOnyx} from 'react-native-onyx';
import ONYXKEYS from '../../../ONYXKEYS';
import styles from '../../../styles/styles';
import ReportActionItemFragment from './ReportActionItemFragment';
import ReportActionPropTypes from './ReportActionPropTypes';

const propTypes = {
// The report action
action: PropTypes.shape(ReportActionPropTypes).isRequired,

// Information about the network
network: PropTypes.shape({
// Is the network currently offline or not
isOffline: PropTypes.bool,
}),
};

const defaultProps = {
network: {isOffline: false},
};

const ReportActionItemMessage = ({action}) => {
// reportActionID is only present when the action is saved onto server.
const isUnsent = action.loading && !action.reportActionID;
const ReportActionItemMessage = ({action, network}) => {
const isUnsent = network.isOffline && action.loading;
return (
<View style={[styles.chatItemMessage, isUnsent && styles.chatItemUnsentMessage]}>
{_.map(_.compact(action.message), (fragment, index) => (
Expand All @@ -29,6 +40,11 @@ const ReportActionItemMessage = ({action}) => {
};

ReportActionItemMessage.propTypes = propTypes;
ReportActionItemMessage.defaultProps = defaultProps;
ReportActionItemMessage.displayName = 'ReportActionItemMessage';

export default ReportActionItemMessage;
export default withOnyx({
network: {
key: ONYXKEYS.NETWORK,
},
})(ReportActionItemMessage);