Remove context menu for system and ephemeral messages (#981)
This commit is contained in:
parent
ace45ae0dd
commit
76b8fba358
5 changed files with 35 additions and 12 deletions
|
|
@ -39,11 +39,11 @@ export default class OptionsContext extends PureComponent {
|
|||
};
|
||||
|
||||
handleHideUnderlay = () => {
|
||||
this.props.toggleSelected(false);
|
||||
this.props.toggleSelected(false, this.props.actions.length > 0);
|
||||
};
|
||||
|
||||
handleShowUnderlay = () => {
|
||||
this.props.toggleSelected(true);
|
||||
this.props.toggleSelected(true, this.props.actions.length > 0);
|
||||
};
|
||||
|
||||
render() {
|
||||
|
|
|
|||
|
|
@ -17,12 +17,24 @@ export default class OptionsContext extends PureComponent {
|
|||
actions: []
|
||||
};
|
||||
|
||||
handleHideUnderlay = () => {
|
||||
if (!this.isShowing) {
|
||||
this.props.toggleSelected(false, false);
|
||||
}
|
||||
};
|
||||
|
||||
handleShowUnderlay = () => {
|
||||
this.props.toggleSelected(true, false);
|
||||
};
|
||||
|
||||
handleHide = () => {
|
||||
this.props.toggleSelected(false);
|
||||
this.isShowing = false;
|
||||
this.props.toggleSelected(false, this.props.actions.length > 0);
|
||||
};
|
||||
|
||||
handleShow = () => {
|
||||
this.props.toggleSelected(true);
|
||||
this.isShowing = this.props.actions.length > 0;
|
||||
this.props.toggleSelected(true, this.isShowing);
|
||||
};
|
||||
|
||||
hide = () => {
|
||||
|
|
@ -33,14 +45,21 @@ export default class OptionsContext extends PureComponent {
|
|||
this.refs.toolTip.showMenu();
|
||||
};
|
||||
|
||||
handlePress = () => {
|
||||
this.props.toggleSelected(false, this.props.actions.length > 0);
|
||||
this.props.onPress();
|
||||
};
|
||||
|
||||
render() {
|
||||
return (
|
||||
<ToolTip
|
||||
onHideUnderlay={this.handleHideUnderlay}
|
||||
onShowUnderlay={this.handleShowUnderlay}
|
||||
ref='toolTip'
|
||||
actions={this.props.actions}
|
||||
arrowDirection='down'
|
||||
longPress={true}
|
||||
onPress={this.props.onPress}
|
||||
onPress={this.handlePress}
|
||||
underlayColor='transparent'
|
||||
onShow={this.handleShow}
|
||||
onHide={this.handleHide}
|
||||
|
|
|
|||
|
|
@ -281,15 +281,17 @@ class Post extends PureComponent {
|
|||
};
|
||||
|
||||
viewUserProfile = () => {
|
||||
const {isSearchResult} = this.props;
|
||||
const {isSearchResult, tooltipVisible} = this.props;
|
||||
|
||||
if (!isSearchResult) {
|
||||
if (!isSearchResult && !tooltipVisible) {
|
||||
preventDoubleTap(this.goToUserProfile, this);
|
||||
}
|
||||
};
|
||||
|
||||
toggleSelected = (selected) => {
|
||||
this.props.actions.setPostTooltipVisible(selected);
|
||||
toggleSelected = (selected, tooltip) => {
|
||||
if (tooltip) {
|
||||
this.props.actions.setPostTooltipVisible(selected);
|
||||
}
|
||||
this.setState({selected});
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ import {flagPost, unflagPost} from 'mattermost-redux/actions/posts';
|
|||
import {Posts} from 'mattermost-redux/constants';
|
||||
import {getPost} from 'mattermost-redux/selectors/entities/posts';
|
||||
import {getMyPreferences} from 'mattermost-redux/selectors/entities/preferences';
|
||||
import {isPostFlagged, isSystemMessage} from 'mattermost-redux/utils/post_utils';
|
||||
import {isPostFlagged, isPostEphemeral, isSystemMessage} from 'mattermost-redux/utils/post_utils';
|
||||
|
||||
import {getTheme} from 'app/selectors/preferences';
|
||||
|
||||
|
|
@ -27,6 +27,7 @@ function mapStateToProps(state, ownProps) {
|
|||
isFailed: post.failed,
|
||||
isFlagged: isPostFlagged(post.id, myPreferences),
|
||||
isPending: post.id === post.pending_post_id,
|
||||
isPostEphemeral: isPostEphemeral(post),
|
||||
isSystemMessage: isSystemMessage(post),
|
||||
message: post.message,
|
||||
theme: getTheme(state)
|
||||
|
|
|
|||
|
|
@ -39,6 +39,7 @@ class PostBody extends PureComponent {
|
|||
isFailed: PropTypes.bool,
|
||||
isFlagged: PropTypes.bool,
|
||||
isPending: PropTypes.bool,
|
||||
isPostEphemeral: PropTypes.bool,
|
||||
isSearchResult: PropTypes.bool,
|
||||
isSystemMessage: PropTypes.bool,
|
||||
message: PropTypes.string,
|
||||
|
|
@ -133,6 +134,7 @@ class PostBody extends PureComponent {
|
|||
isFailed,
|
||||
isFlagged,
|
||||
isPending,
|
||||
isPostEphemeral,
|
||||
isSearchResult,
|
||||
isSystemMessage,
|
||||
intl,
|
||||
|
|
@ -157,7 +159,7 @@ class PostBody extends PureComponent {
|
|||
const isPendingOrFailedPost = isPending || isFailed;
|
||||
|
||||
// we should check for the user roles and permissions
|
||||
if (!isPendingOrFailedPost && !isSearchResult) {
|
||||
if (!isPendingOrFailedPost && !isSearchResult && !isSystemMessage && !isPostEphemeral) {
|
||||
if (isFlagged) {
|
||||
actions.push({
|
||||
text: formatMessage({id: 'post_info.mobile.unflag', defaultMessage: 'Unflag'}),
|
||||
|
|
@ -219,7 +221,6 @@ class PostBody extends PureComponent {
|
|||
body = (
|
||||
<TouchableHighlight
|
||||
onHideUnderlay={this.handleHideUnderlay}
|
||||
onLongPress={this.show}
|
||||
onPress={onPress}
|
||||
onShowUnderlay={this.handleShowUnderlay}
|
||||
underlayColor='transparent'
|
||||
|
|
|
|||
Loading…
Reference in a new issue