From 8e9146e5c905d823eab32830f94ca1907a6cda3a Mon Sep 17 00:00:00 2001 From: Elias Nahum Date: Fri, 7 Sep 2018 11:35:19 -0300 Subject: [PATCH] fix contextOption for post (#2086) * fix contextOption for post * feedback review --- .../options_context/options_context.ios.js | 35 +++++++++---------- app/components/post/post.js | 8 +---- 2 files changed, 18 insertions(+), 25 deletions(-) diff --git a/app/components/options_context/options_context.ios.js b/app/components/options_context/options_context.ios.js index 0e89b3f2d..3fd7c88c1 100644 --- a/app/components/options_context/options_context.ios.js +++ b/app/components/options_context/options_context.ios.js @@ -27,34 +27,34 @@ export default class OptionsContext extends PureComponent { }; } + handleHide = () => { + this.isShowing = false; + this.props.toggleSelected(false); + }; + handleHideUnderlay = () => { if (!this.isShowing) { - this.props.toggleSelected(false, false); + this.props.toggleSelected(false); } }; handleShowUnderlay = () => { - this.props.toggleSelected(true, false); - }; - - handleHide = () => { - this.isShowing = false; - this.props.toggleSelected(false, this.props.getPostActions().length > 0); - }; - - handleShow = () => { - this.isShowing = this.props.getPostActions().length > 0; - this.props.toggleSelected(true, this.isShowing); + this.show(); + this.props.toggleSelected(true); + this.isShowing = this.state.actions.length > 0; }; hide = () => { + this.setState({ + actions: this.props.getPostActions(), + }); + if (this.refs.toolTip) { this.refs.toolTip.hideMenu(); } - this.setState({ - actions: this.props.getPostActions(), - }); + this.isShowing = false; + this.props.toggleSelected(false); }; show = (additionalAction) => { @@ -74,7 +74,7 @@ export default class OptionsContext extends PureComponent { }; handlePress = () => { - this.props.toggleSelected(false, this.props.getPostActions().length > 0); + this.props.toggleSelected(false); this.props.onPress(); }; @@ -87,10 +87,9 @@ export default class OptionsContext extends PureComponent { actions={this.state.actions} arrowDirection='down' longPress={true} + onHide={this.handleHide} onPress={this.handlePress} underlayColor='transparent' - onShow={this.handleShow} - onHide={this.handleHide} > {this.props.children} diff --git a/app/components/post/post.js b/app/components/post/post.js index 37bea8265..185f911ab 100644 --- a/app/components/post/post.js +++ b/app/components/post/post.js @@ -110,10 +110,6 @@ export default class Post extends PureComponent { this.props.actions.insertToDraft(`@${username} `); }; - handleEditDisable = () => { - this.setState({canEdit: false}); - }; - handlePostDelete = () => { const {formatMessage} = this.context.intl; const {actions, currentUserId, post} = this.props; @@ -313,9 +309,7 @@ export default class Post extends PureComponent { }); toggleSelected = (selected) => { - if (!getToolTipVisible()) { - this.setState({selected}); - } + this.setState({selected}); }; handleCopyText = (text) => {