disable message contextmenu on group chats when kicked

pull/1074/head
Audric Ackermann 6 years ago
parent f48136678e
commit ab77b0f9a5
No known key found for this signature in database
GPG Key ID: 999F434D76324AD4

@ -113,6 +113,8 @@
this.propsForMessage = this.getPropsForMessage(); this.propsForMessage = this.getPropsForMessage();
} }
}; };
const triggerChange = () => this.trigger('change');
this.on('change', generateProps); this.on('change', generateProps);
const applicableConversationChanges = const applicableConversationChanges =
@ -120,8 +122,11 @@
const conversation = this.getConversation(); const conversation = this.getConversation();
const fromContact = this.getIncomingContact(); const fromContact = this.getIncomingContact();
this.listenTo(conversation, applicableConversationChanges, generateProps); this.listenTo(conversation, applicableConversationChanges, generateProps);
// trigger a change event on this component.
// this will call generateProps and refresh the Message.tsx component with new props
this.listenTo(conversation, 'disable:input', triggerChange );
if (fromContact) { if (fromContact) {
this.listenTo( this.listenTo(
fromContact, fromContact,
@ -703,6 +708,7 @@
multiSelectMode: conversation && conversation.selectedMessages.size > 0, multiSelectMode: conversation && conversation.selectedMessages.size > 0,
isPublic: !!this.get('isPublic'), isPublic: !!this.get('isPublic'),
isRss: !!this.get('isRss'), isRss: !!this.get('isRss'),
isKickedFromGroup: conversation.get('isKickedFromGroup'),
senderIsModerator: senderIsModerator:
!!this.get('isPublic') && !!this.get('isPublic') &&
conversation && conversation &&

@ -100,6 +100,7 @@ export interface Props {
isPublic?: boolean; isPublic?: boolean;
isRss?: boolean; isRss?: boolean;
selected: boolean; selected: boolean;
isKickedFromGroup: boolean;
// whether or not to show check boxes // whether or not to show check boxes
multiSelectMode: boolean; multiSelectMode: boolean;
@ -782,11 +783,12 @@ export class Message extends React.PureComponent<Props, State> {
attachments, attachments,
direction, direction,
disableMenu, disableMenu,
isKickedFromGroup,
onDownload, onDownload,
onReply, onReply,
} = this.props; } = this.props;
if (!isCorrectSide || disableMenu) { if (!isCorrectSide || disableMenu || isKickedFromGroup) {
return null; return null;
} }
@ -1051,12 +1053,14 @@ export class Message extends React.PureComponent<Props, State> {
return false; return false;
} }
// tslint:disable-next-line: cyclomatic-complexity
public render() { public render() {
const { const {
authorPhoneNumber, authorPhoneNumber,
authorColor, authorColor,
direction, direction,
id, id,
isKickedFromGroup,
isRss, isRss,
timestamp, timestamp,
selected, selected,
@ -1106,7 +1110,7 @@ export class Message extends React.PureComponent<Props, State> {
divClasses.push('public-chat-message-wrapper'); divClasses.push('public-chat-message-wrapper');
} }
const enableContextMenu = !isRss && !multiSelectMode; const enableContextMenu = !isRss && !multiSelectMode && !isKickedFromGroup;
return ( return (
<div className={classNames(divClasses)}> <div className={classNames(divClasses)}>
@ -1136,7 +1140,7 @@ export class Message extends React.PureComponent<Props, State> {
}} }}
> >
{this.renderError(isIncoming)} {this.renderError(isIncoming)}
{isRss ? null : this.renderMenu(!isIncoming, triggerId)} {isRss || isKickedFromGroup ? null : this.renderMenu(!isIncoming, triggerId)}
<div <div
className={classNames( className={classNames(
'module-message__container', 'module-message__container',

Loading…
Cancel
Save