Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove withDrawerState and isDrawerOpen #3

Merged
merged 8 commits into from
Mar 27, 2023
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
42 changes: 0 additions & 42 deletions src/components/withDrawerState.js

This file was deleted.

8 changes: 3 additions & 5 deletions src/pages/home/ReportScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import compose from '../../libs/compose';
import networkPropTypes from '../../components/networkPropTypes';
import withWindowDimensions, {windowDimensionsPropTypes} from '../../components/withWindowDimensions';
import OfflineWithFeedback from '../../components/OfflineWithFeedback';
import withDrawerState, {withDrawerPropTypes} from '../../components/withDrawerState';
import ReportFooter from './report/ReportFooter';
import Banner from '../../components/Banner';
import withLocalize from '../../components/withLocalize';
Expand All @@ -34,6 +33,7 @@ import FullPageNotFoundView from '../../components/BlockingViews/FullPageNotFoun
import ReportHeaderSkeletonView from '../../components/ReportHeaderSkeletonView';
import withViewportOffsetTop, {viewportOffsetTopPropTypes} from '../../components/withViewportOffsetTop';
import * as ReportActionsUtils from '../../libs/ReportActionsUtils';
import withNavigationFocus from '../../components/withNavigationFocus';

const propTypes = {
/** Navigation route context info provided by react navigation */
Expand Down Expand Up @@ -73,7 +73,6 @@ const propTypes = {
network: networkPropTypes.isRequired,

...windowDimensionsPropTypes,
...withDrawerPropTypes,
...viewportOffsetTopPropTypes,
};

Expand Down Expand Up @@ -204,7 +203,7 @@ class ReportScreen extends React.Component {
const isLoadingInitialReportActions = _.isEmpty(this.props.reportActions) && this.props.report.isLoadingReportActions;

// When the ReportScreen is not open/in the viewport, we want to "freeze" it for performance reasons
const freeze = this.props.isSmallScreenWidth && this.props.isDrawerOpen;
const freeze = this.props.isSmallScreenWidth && !this.props.isFocused;

// the moment the ReportScreen becomes unfrozen we want to start the animation of the placeholder skeleton content
// (which is shown, until all the actual views of the ReportScreen have been rendered)
Expand Down Expand Up @@ -280,7 +279,6 @@ class ReportScreen extends React.Component {
report={this.props.report}
session={this.props.session}
isComposerFullSize={this.props.isComposerFullSize}
isDrawerOpen={this.props.isDrawerOpen}
parentViewHeight={this.state.skeletonViewContainerHeight}
/>
<ReportFooter
Expand Down Expand Up @@ -319,7 +317,7 @@ export default compose(
withViewportOffsetTop,
withLocalize,
withWindowDimensions,
withDrawerState,
withNavigationFocus,
withNetwork(),
withOnyx({
isSidebarLoaded: {
Expand Down
14 changes: 1 addition & 13 deletions src/pages/home/report/ReportActionCompose.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import AttachmentModal from '../../../components/AttachmentModal';
import compose from '../../../libs/compose';
import PopoverMenu from '../../../components/PopoverMenu';
import withWindowDimensions, {windowDimensionsPropTypes} from '../../../components/withWindowDimensions';
import withDrawerState from '../../../components/withDrawerState';
import withLocalize, {withLocalizePropTypes} from '../../../components/withLocalize';
import willBlurTextInputOnTapOutside from '../../../libs/willBlurTextInputOnTapOutside';
import CONST from '../../../CONST';
Expand All @@ -39,7 +38,6 @@ import * as User from '../../../libs/actions/User';
import Tooltip from '../../../components/Tooltip';
import EmojiPickerButton from '../../../components/EmojiPicker/EmojiPickerButton';
import * as DeviceCapabilities from '../../../libs/DeviceCapabilities';
import toggleReportActionComposeView from '../../../libs/toggleReportActionComposeView';
import OfflineIndicator from '../../../components/OfflineIndicator';
import ExceededCommentLength from '../../../components/ExceededCommentLength';
import withNavigationFocus from '../../../components/withNavigationFocus';
Expand Down Expand Up @@ -80,9 +78,6 @@ const propTypes = {
/** Array of report actions for this report */
reportActions: PropTypes.arrayOf(PropTypes.shape(reportActionPropTypes)),

/** Is the report view covered by the drawer */
isDrawerOpen: PropTypes.bool.isRequired,

/** Is the window width narrow, like on a mobile device */
isSmallScreenWidth: PropTypes.bool.isRequired,

Expand Down Expand Up @@ -208,11 +203,6 @@ class ReportActionCompose extends React.Component {
}

componentDidUpdate(prevProps) {
const sidebarOpened = !prevProps.isDrawerOpen && this.props.isDrawerOpen;
if (sidebarOpened) {
toggleReportActionComposeView(true);
}

// We want to focus or refocus the input when a modal has been closed and the underlying screen is focused.
// We avoid doing this on native platforms since the software keyboard popping
// open creates a jarring and broken UX.
Expand Down Expand Up @@ -662,7 +652,6 @@ class ReportActionCompose extends React.Component {
&& !this.props.isComposerFullSize;

// Prevents focusing and showing the keyboard while the drawer is covering the chat.
const isComposeDisabled = this.props.isDrawerOpen && this.props.isSmallScreenWidth;
const isBlockedFromConcierge = ReportUtils.chatIncludesConcierge(this.props.report) && User.isBlockedFromConcierge(this.props.blockedFromConcierge);
const inputPlaceholder = this.getInputPlaceholder();
const shouldUseFocusedColor = !isBlockedFromConcierge && !this.props.disabled && (this.state.isFocused || this.state.isDraggingOver);
Expand Down Expand Up @@ -816,7 +805,7 @@ class ReportActionCompose extends React.Component {
onPasteFile={displayFileInModal}
shouldClear={this.state.textInputShouldClear}
onClear={() => this.setTextInputShouldClear(false)}
isDisabled={isComposeDisabled || isBlockedFromConcierge || this.props.disabled}
isDisabled={isBlockedFromConcierge || this.props.disabled}
selection={this.state.selection}
onSelectionChange={this.onSelectionChange}
isFullComposerAvailable={this.state.isFullComposerAvailable}
Expand Down Expand Up @@ -911,7 +900,6 @@ ReportActionCompose.defaultProps = defaultProps;

export default compose(
withWindowDimensions,
withDrawerState,
withNavigationFocus,
withLocalize,
withNetwork(),
Expand Down
6 changes: 1 addition & 5 deletions src/pages/home/report/ReportActionsList.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import React from 'react';
import {Animated} from 'react-native';
import _ from 'underscore';
import InvertedFlatList from '../../../components/InvertedFlatList';
import withDrawerState, {withDrawerPropTypes} from '../../../components/withDrawerState';
import compose from '../../../libs/compose';
import * as ReportScrollManager from '../../../libs/ReportScrollManager';
import styles from '../../../styles/styles';
Expand Down Expand Up @@ -52,7 +51,6 @@ const propTypes = {
/** Information about the network */
network: networkPropTypes.isRequired,

...withDrawerPropTypes,
...windowDimensionsPropTypes,
};

Expand Down Expand Up @@ -145,7 +143,6 @@ class ReportActionsList extends React.Component {
render() {
// Native mobile does not render updates flatlist the changes even though component did update called.
// To notify there something changes we can use extraData prop to flatlist
const extraData = (!this.props.isDrawerOpen && this.props.isSmallScreenWidth) ? this.props.newMarkerReportActionID : undefined;
const shouldShowReportRecipientLocalTime = ReportUtils.canShowReportRecipientLocalTime(this.props.personalDetails, this.props.report);
return (
<Animated.View style={[StyleUtils.fade(this.state.fadeInAnimation), styles.flex1]}>
Expand Down Expand Up @@ -195,7 +192,7 @@ class ReportActionsList extends React.Component {
this.props.onLayout(event);
}}
onScroll={this.props.onScroll}
extraData={extraData}
extraData={this.props.newMarkerReportActionID}
/>
</Animated.View>
);
Expand All @@ -206,7 +203,6 @@ ReportActionsList.propTypes = propTypes;
ReportActionsList.defaultProps = defaultProps;

export default compose(
withDrawerState,
withWindowDimensions,
withPersonalDetails(),
withNetwork(),
Expand Down
21 changes: 4 additions & 17 deletions src/pages/home/report/ReportActionsView.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import Timing from '../../../libs/actions/Timing';
import CONST from '../../../CONST';
import compose from '../../../libs/compose';
import withWindowDimensions, {windowDimensionsPropTypes} from '../../../components/withWindowDimensions';
import {withDrawerPropTypes} from '../../../components/withDrawerState';
import * as ReportScrollManager from '../../../libs/ReportScrollManager';
import withLocalize, {withLocalizePropTypes} from '../../../components/withLocalize';
import Performance from '../../../libs/Performance';
Expand All @@ -23,6 +22,7 @@ import EmojiPicker from '../../../components/EmojiPicker/EmojiPicker';
import * as ReportActionsUtils from '../../../libs/ReportActionsUtils';
import * as ReportUtils from '../../../libs/ReportUtils';
import reportPropTypes from '../../reportPropTypes';
import withNavigationFocus from '../../../components/withNavigationFocus';

const propTypes = {
/** The report currently being looked at */
Expand All @@ -44,7 +44,6 @@ const propTypes = {
network: networkPropTypes.isRequired,

...windowDimensionsPropTypes,
...withDrawerPropTypes,
...withLocalizePropTypes,
};

Expand Down Expand Up @@ -161,10 +160,6 @@ class ReportActionsView extends React.Component {
return true;
}

if (this.props.isDrawerOpen !== nextProps.isDrawerOpen) {
return true;
}

if (lodashGet(this.props.report, 'hasOutstandingIOU') !== lodashGet(nextProps.report, 'hasOutstandingIOU')) {
return true;
}
Expand Down Expand Up @@ -193,9 +188,8 @@ class ReportActionsView extends React.Component {

// If the report was previously hidden by the side bar, or the view is expanded from mobile to desktop layout
// we update the new marker position, mark the report as read, and fetch new report actions
const didSidebarClose = prevProps.isDrawerOpen && !this.props.isDrawerOpen;
const didScreenSizeIncrease = prevProps.isSmallScreenWidth && !this.props.isSmallScreenWidth;
const didReportBecomeVisible = isReportFullyVisible && (didSidebarClose || didScreenSizeIncrease);
const didReportBecomeVisible = isReportFullyVisible && didScreenSizeIncrease;
if (didReportBecomeVisible) {
this.setState({
newMarkerReportActionID: ReportUtils.isUnread(this.props.report)
Expand All @@ -213,14 +207,6 @@ class ReportActionsView extends React.Component {
});
}

// When the user navigates to the LHN the ReportActionsView doesn't unmount and just remains hidden.
// The next time we navigate to the same report (e.g. by swiping or tapping the LHN row) we want the new marker to clear.
const didSidebarOpen = !prevProps.isDrawerOpen && this.props.isDrawerOpen;
const didUserNavigateToSidebarAfterReadingReport = didSidebarOpen && !ReportUtils.isUnread(this.props.report);
if (didUserNavigateToSidebarAfterReadingReport) {
this.setState({newMarkerReportActionID: ''});
}

// Checks to see if a report comment has been manually "marked as unread". All other times when the lastReadTime
// changes it will be because we marked the entire report as read.
const didManuallyMarkReportAsUnread = (prevProps.report.lastReadTime !== this.props.report.lastReadTime)
Expand Down Expand Up @@ -257,7 +243,7 @@ class ReportActionsView extends React.Component {
* @returns {Boolean}
*/
getIsReportFullyVisible() {
const isSidebarCoveringReportView = this.props.isSmallScreenWidth && this.props.isDrawerOpen;
const isSidebarCoveringReportView = this.props.isSmallScreenWidth && !this.props.isFocused;
return Visibility.isVisible() && !isSidebarCoveringReportView;
}

Expand Down Expand Up @@ -373,6 +359,7 @@ ReportActionsView.defaultProps = defaultProps;
export default compose(
Performance.withRenderTrace({id: '<ReportActionsView> rendering'}),
withWindowDimensions,
withNavigationFocus,
withLocalize,
withNetwork(),
)(ReportActionsView);
6 changes: 4 additions & 2 deletions src/pages/home/sidebar/SidebarLinks.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import LHNOptionsList from '../../../components/LHNOptionsList/LHNOptionsList';
import SidebarUtils from '../../../libs/SidebarUtils';
import reportPropTypes from '../../reportPropTypes';
import OfflineWithFeedback from '../../../components/OfflineWithFeedback';
import withNavigationFocus from '../../../components/withNavigationFocus';

const propTypes = {
/** Toggles the navigation menu open and closed */
Expand Down Expand Up @@ -137,7 +138,7 @@ class SidebarLinks extends React.Component {

return (
<View
accessibilityElementsHidden={this.props.isSmallScreenWidth && !this.props.isDrawerOpen}
accessibilityElementsHidden={this.props.isSmallScreenWidth && !this.props.isFocused}
accessibilityLabel="List of chats"
style={[styles.flex1, styles.h100]}
>
Expand Down Expand Up @@ -183,7 +184,7 @@ class SidebarLinks extends React.Component {
</OfflineWithFeedback>
</TouchableOpacity>
</View>
<Freeze freeze={this.props.isSmallScreenWidth && !this.props.isDrawerOpen && this.isSidebarLoaded}>
<Freeze freeze={this.props.isSmallScreenWidth && !this.props.isFocused && this.isSidebarLoaded}>
<LHNOptionsList
contentContainerStyles={[
styles.sidebarListContainer,
Expand Down Expand Up @@ -278,6 +279,7 @@ const policySelector = policy => policy && ({
export default compose(
withLocalize,
withCurrentUserPersonalDetails,
withNavigationFocus,
withWindowDimensions,
withOnyx({
// Note: It is very important that the keys subscribed to here are the same
Expand Down
8 changes: 1 addition & 7 deletions src/pages/home/sidebar/SidebarScreen/BaseSidebarScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,7 @@ import ROUTES from '../../../../ROUTES';
import Timing from '../../../../libs/actions/Timing';
import CONST from '../../../../CONST';
import Performance from '../../../../libs/Performance';
import withDrawerState from '../../../../components/withDrawerState';
import withWindowDimensions, {windowDimensionsPropTypes} from '../../../../components/withWindowDimensions';
import compose from '../../../../libs/compose';
import sidebarPropTypes from './sidebarPropTypes';

const propTypes = {
Expand Down Expand Up @@ -60,7 +58,6 @@ class BaseSidebarScreen extends Component {
insets={insets}
onAvatarClick={this.navigateToSettings}
isSmallScreenWidth={this.props.isSmallScreenWidth}
isDrawerOpen={this.props.isDrawerOpen}
reportIDFromRoute={this.props.reportIDFromRoute}
onLayout={this.props.onLayout}
/>
Expand All @@ -75,7 +72,4 @@ class BaseSidebarScreen extends Component {

BaseSidebarScreen.propTypes = propTypes;

export default compose(
withWindowDimensions,
withDrawerState,
)(BaseSidebarScreen);
export default withWindowDimensions(BaseSidebarScreen);
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import ONYXKEYS from '../../../../ONYXKEYS';
import withNavigation from '../../../../components/withNavigation';
import * as Welcome from '../../../../libs/actions/Welcome';
import withNavigationFocus from '../../../../components/withNavigationFocus';
import withDrawerState from '../../../../components/withDrawerState';

/**
* @param {Object} [policy]
Expand Down Expand Up @@ -94,11 +93,6 @@ class FloatingActionButtonAndPopover extends React.Component {
* @return {Boolean}
*/
didScreenBecomeInactive(prevProps) {
// When the Drawer gets closed and ReportScreen is shown
if (!this.props.isDrawerOpen && prevProps.isDrawerOpen) {
return true;
}

// When any other page is opened over LHN
if (!this.props.isFocused && prevProps.isFocused) {
return true;
Expand All @@ -114,11 +108,6 @@ class FloatingActionButtonAndPopover extends React.Component {
* @return {Boolean}
*/
isScreenInactive() {
// When drawer is closed and Report page is open
if (this.props.isSmallScreenWidth && !this.props.isDrawerOpen) {
return true;
}

// When any other page is open
if (!this.props.isFocused) {
return true;
Expand Down Expand Up @@ -237,7 +226,6 @@ export default compose(
withLocalize,
withNavigation,
withNavigationFocus,
withDrawerState,
withWindowDimensions,
withOnyx({
allPolicies: {
Expand Down