Skip to content

Commit

Permalink
consolidate Onyx.connect call
Browse files Browse the repository at this point in the history
Fix the context methods

more report screen organizing

create more context helpers

remove bad merged code

remove unusued imports and fix style

undo context changes

remove unused line

add missing session
  • Loading branch information
marcaaron committed Aug 12, 2021
1 parent 2fc68a5 commit fd2f824
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 29 deletions.
2 changes: 1 addition & 1 deletion src/components/createOnyxContext.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export default (onyxKeyName) => {
},
})(Provider);

const withOnyxKey = ({propName = onyxKeyName, transformValue = () => {}} = {}) => (WrappedComponent) => {
const withOnyxKey = ({propName = onyxKeyName, transformValue} = {}) => (WrappedComponent) => {
const Consumer = forwardRef((props, ref) => (
<Context.Consumer>
{(value) => {
Expand Down
9 changes: 8 additions & 1 deletion src/pages/home/ReportScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,14 @@ class ReportScreen extends React.Component {

<View nativeID={CONST.REPORT.DROP_NATIVE_ID} style={[styles.flex1, styles.justifyContentEnd]}>
<FullScreenLoadingIndicator visible={this.shouldShowLoader()} />
{!this.shouldShowLoader() && <ReportActionsView reportID={reportID} />}
{!this.shouldShowLoader() && (
<ReportActionsView
reportID={reportID}
reportActions={this.props.reportActions}
report={this.props.report}
session={this.props.session}
/>
)}
{this.props.session.shouldShowComposeInput && (
<SwipeableView onSwipeDown={() => Keyboard.dismiss()}>
<ReportActionCompose
Expand Down
16 changes: 3 additions & 13 deletions src/pages/home/report/ReportActionCompose.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ import Text from '../../../components/Text';
import {participantPropTypes} from '../sidebar/optionPropTypes';
import currentUserPersonalDetailsPropsTypes from '../../settings/Profile/currentUserPersonalDetailsPropsTypes';
import ParticipantLocalTime from './ParticipantLocalTime';
import {withNetwork, withPersonalDetails} from '../../../components/OnyxProvider';

const propTypes = {
/** Beta features list */
Expand Down Expand Up @@ -673,6 +674,8 @@ export default compose(
withDrawerState,
withNavigationFocus,
withLocalize,
withPersonalDetails(),
withNetwork(),
withOnyx({
betas: {
key: ONYXKEYS.BETAS,
Expand All @@ -683,22 +686,9 @@ export default compose(
modal: {
key: ONYXKEYS.MODAL,
},
network: {
key: ONYXKEYS.NETWORK,
},
myPersonalDetails: {
key: ONYXKEYS.MY_PERSONAL_DETAILS,
},
personalDetails: {
key: ONYXKEYS.PERSONAL_DETAILS,
},
reportActions: {
key: ({reportID}) => `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${reportID}`,
canEvict: false,
},
report: {
key: ({reportID}) => `${ONYXKEYS.COLLECTION.REPORT}${reportID}`,
},
blockedFromConcierge: {
key: ONYXKEYS.NVP_BLOCKED_FROM_CONCIERGE,
},
Expand Down
14 changes: 0 additions & 14 deletions src/pages/home/report/ReportActionsView.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import {
import PropTypes from 'prop-types';
import _ from 'underscore';
import lodashGet from 'lodash/get';
import {withOnyx} from 'react-native-onyx';
import Text from '../../../components/Text';
import {
fetchActions,
Expand All @@ -18,7 +17,6 @@ import {
subscribeToReportTypingEvents,
unsubscribeFromReportChannel,
} from '../../../libs/actions/Report';
import ONYXKEYS from '../../../ONYXKEYS';
import ReportActionItem from './ReportActionItem';
import styles from '../../../styles/styles';
import ReportActionPropTypes from './ReportActionPropTypes';
Expand Down Expand Up @@ -457,16 +455,4 @@ export default compose(
withWindowDimensions,
withDrawerState,
withLocalize,
withOnyx({
report: {
key: ({reportID}) => `${ONYXKEYS.COLLECTION.REPORT}${reportID}`,
},
reportActions: {
key: ({reportID}) => `${ONYXKEYS.COLLECTION.REPORT_ACTIONS}${reportID}`,
canEvict: false,
},
session: {
key: ONYXKEYS.SESSION,
},
}),
)(ReportActionsView);

0 comments on commit fd2f824

Please sign in to comment.