Merge pull request #474 from BeaudanBrown/hide-menus

Remove most of the right click and cog menu options for the public chats
pull/478/head
Beaudan Campbell-Brown 6 years ago committed by GitHub
commit e70b875226
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -1041,11 +1041,27 @@
"message": "Delete messages",
"description": "Menu item for deleting messages, title case."
},
"deletePublicConversationConfirmation": {
"message":
"Permanently delete the messages locally from this public channel?",
"description":
"Confirmation dialog text that asks the user if they really wish to delete the public channel messages locally. Answer buttons use the strings 'ok' and 'cancel'. The deletion is permanent, i.e. it cannot be undone."
},
"deleteConversationConfirmation": {
"message": "Permanently delete this conversation?",
"description":
"Confirmation dialog text that asks the user if they really wish to delete the conversation. Answer buttons use the strings 'ok' and 'cancel'. The deletion is permanent, i.e. it cannot be undone."
},
"deletePublicChannel": {
"message": "Leave public channel",
"description":
"Confirmation dialog title that asks the user if they really wish to delete a public channel. Answer buttons use the strings 'ok' and 'cancel'. The deletion is permanent, i.e. it cannot be undone."
},
"deletePublicChannelConfirmation": {
"message": "Leave this public channel?",
"description":
"Confirmation dialog text that tells the user what will happen if they leave the public channel."
},
"deleteContact": {
"message": "Delete contact",
"description":

@ -195,7 +195,7 @@
return this.id === this.ourNumber;
},
isPublic() {
return this.id.match(/^publicChat:/);
return this.id && this.id.match(/^publicChat:/);
},
isClosable() {
return !this.isRss() || this.get('closable');
@ -445,6 +445,7 @@
color,
type: this.isPrivate() ? 'direct' : 'group',
isMe: this.isMe(),
isPublic: this.isPublic(),
isClosable: this.isClosable(),
isTyping: typingKeys.length > 0,
lastUpdated: this.get('timestamp'),
@ -2311,10 +2312,17 @@
},
deleteContact() {
Whisper.events.trigger('showConfirmationDialog', {
message: i18n('deleteContactConfirmation'),
onOk: () => ConversationController.deleteContact(this.id),
});
if (this.isPublic()) {
Whisper.events.trigger('showConfirmationDialog', {
message: i18n('deletePublicChannelConfirmation'),
onOk: () => ConversationController.deleteContact(this.id),
});
} else {
Whisper.events.trigger('showConfirmationDialog', {
message: i18n('deleteContactConfirmation'),
onOk: () => ConversationController.deleteContact(this.id),
});
}
},
async deletePublicMessage(message) {
@ -2343,10 +2351,17 @@
},
deleteMessages() {
Whisper.events.trigger('showConfirmationDialog', {
message: i18n('deleteConversationConfirmation'),
onOk: () => this.destroyMessages(),
});
if (this.isPublic()) {
Whisper.events.trigger('showConfirmationDialog', {
message: i18n('deletePublicConversationConfirmation'),
onOk: () => ConversationController.deleteContact(this.id),
});
} else {
Whisper.events.trigger('showConfirmationDialog', {
message: i18n('deleteContactConfirmation'),
onOk: () => ConversationController.deleteContact(this.id),
});
}
},
async destroyMessages() {

@ -206,6 +206,7 @@
isGroup: !this.model.isPrivate(),
isOnline: this.model.isOnline(),
isArchived: this.model.get('isArchived'),
isPublic: this.model.isPublic(),
expirationSettingName,
showBackButton: Boolean(this.panels && this.panels.length),
@ -1510,20 +1511,37 @@
},
destroyMessages() {
Whisper.events.trigger('showConfirmationDialog', {
message: i18n('deleteConversationConfirmation'),
onOk: async () => {
try {
await this.model.destroyMessages();
this.unload('delete messages');
} catch (error) {
window.log.error(
'destroyMessages: Failed to successfully delete conversation',
error && error.stack ? error.stack : error
);
}
},
});
if (this.model.isPublic()) {
Whisper.events.trigger('showConfirmationDialog', {
message: i18n('deletePublicConversationConfirmation'),
onOk: async () => {
try {
await this.model.destroyMessages();
this.unload('delete messages');
} catch (error) {
window.log.error(
'destroyMessages: Failed to successfully delete conversation',
error && error.stack ? error.stack : error
);
}
},
});
} else {
Whisper.events.trigger('showConfirmationDialog', {
message: i18n('deleteConversationConfirmation'),
onOk: async () => {
try {
await this.model.destroyMessages();
this.unload('delete messages');
} catch (error) {
window.log.error(
'destroyMessages: Failed to successfully delete conversation',
error && error.stack ? error.stack : error
);
}
},
});
}
},
showSendConfirmationDialog(e, contacts) {

@ -21,6 +21,7 @@ export type PropsData = {
type: 'group' | 'direct';
avatarPath?: string;
isMe: boolean;
isPublic?: boolean;
isClosable?: boolean;
lastUpdated: number;
@ -165,6 +166,7 @@ export class ConversationListItem extends React.PureComponent<Props> {
isBlocked,
isMe,
isClosable,
isPublic,
hasNickname,
onDeleteContact,
onDeleteMessages,
@ -180,21 +182,31 @@ export class ConversationListItem extends React.PureComponent<Props> {
return (
<ContextMenu id={triggerId}>
{!isMe ? (
{!isPublic && !isMe ? (
<MenuItem onClick={blockHandler}>{blockTitle}</MenuItem>
) : null}
{!isMe ? (
{!isPublic && !isMe ? (
<MenuItem onClick={onChangeNickname}>
{i18n('changeNickname')}
</MenuItem>
) : null}
{!isMe && hasNickname ? (
{!isPublic && !isMe && hasNickname ? (
<MenuItem onClick={onClearNickname}>{i18n('clearNickname')}</MenuItem>
) : null}
<MenuItem onClick={onCopyPublicKey}>{i18n('copyPublicKey')}</MenuItem>
{!isPublic ? (
<MenuItem onClick={onCopyPublicKey}>{i18n('copyPublicKey')}</MenuItem>
) : null}
<MenuItem onClick={onDeleteMessages}>{i18n('deleteMessages')}</MenuItem>
{!isMe && isClosable ? (
<MenuItem onClick={onDeleteContact}>{i18n('deleteContact')}</MenuItem>
!isPublic ? (
<MenuItem onClick={onDeleteContact}>
{i18n('deleteContact')}
</MenuItem>
) : (
<MenuItem onClick={onDeleteContact}>
{i18n('deletePublicChannel')}
</MenuItem>
)
) : null}
</ContextMenu>
);

@ -29,6 +29,7 @@ interface Props {
isClosable?: boolean;
isGroup: boolean;
isArchived: boolean;
isPublic: boolean;
expirationSettingName?: string;
showBackButton: boolean;
@ -200,85 +201,29 @@ export class ConversationHeader extends React.Component<Props> {
public renderMenu(triggerId: string) {
const {
i18n,
isBlocked,
isMe,
isClosable,
isGroup,
isArchived,
isPublic,
onDeleteMessages,
onDeleteContact,
onResetSession,
onSetDisappearingMessages,
// onShowAllMedia,
onShowGroupMembers,
onShowSafetyNumber,
onArchive,
onMoveToInbox,
timerOptions,
onBlockUser,
onUnblockUser,
hasNickname,
onClearNickname,
onChangeNickname,
onCopyPublicKey,
} = this.props;
const disappearingTitle = i18n('disappearingMessages') as any;
const blockTitle = isBlocked ? i18n('unblockUser') : i18n('blockUser');
const blockHandler = isBlocked ? onUnblockUser : onBlockUser;
return (
<ContextMenu id={triggerId}>
<SubMenu title={disappearingTitle}>
{(timerOptions || []).map(item => (
<MenuItem
key={item.value}
onClick={() => {
onSetDisappearingMessages(item.value);
}}
>
{item.name}
</MenuItem>
))}
</SubMenu>
{/* <MenuItem onClick={onShowAllMedia}>{i18n('viewAllMedia')}</MenuItem> */}
{isGroup ? (
<MenuItem onClick={onShowGroupMembers}>
{i18n('showMembers')}
</MenuItem>
) : null}
{!isGroup && !isMe ? (
<MenuItem onClick={onShowSafetyNumber}>
{i18n('showSafetyNumber')}
</MenuItem>
) : null}
{!isGroup ? (
<MenuItem onClick={onResetSession}>{i18n('resetSession')}</MenuItem>
) : null}
{/* Only show the block on other conversations */}
{!isMe ? (
<MenuItem onClick={blockHandler}>{blockTitle}</MenuItem>
) : null}
{!isMe ? (
<MenuItem onClick={onChangeNickname}>
{i18n('changeNickname')}
</MenuItem>
) : null}
{!isMe && hasNickname ? (
<MenuItem onClick={onClearNickname}>{i18n('clearNickname')}</MenuItem>
) : null}
{this.renderPublicMenuItems()}
<MenuItem onClick={onCopyPublicKey}>{i18n('copyPublicKey')}</MenuItem>
{isArchived ? (
<MenuItem onClick={onMoveToInbox}>
{i18n('moveConversationToInbox')}
</MenuItem>
) : (
<MenuItem onClick={onArchive}>{i18n('archiveConversation')}</MenuItem>
)}
<MenuItem onClick={onDeleteMessages}>{i18n('deleteMessages')}</MenuItem>
{!isMe && isClosable ? (
<MenuItem onClick={onDeleteContact}>{i18n('deleteContact')}</MenuItem>
!isPublic ? (
<MenuItem onClick={onDeleteContact}>
{i18n('deleteContact')}
</MenuItem>
) : (
<MenuItem onClick={onDeleteContact}>
{i18n('deletePublicChannel')}
</MenuItem>
)
) : null}
</ContextMenu>
);
@ -303,4 +248,95 @@ export class ConversationHeader extends React.Component<Props> {
</div>
);
}
private renderPublicMenuItems() {
const {
i18n,
isBlocked,
isMe,
isGroup,
isArchived,
isPublic,
onResetSession,
onSetDisappearingMessages,
// onShowAllMedia,
onShowGroupMembers,
onShowSafetyNumber,
onArchive,
onMoveToInbox,
timerOptions,
onBlockUser,
onUnblockUser,
hasNickname,
onClearNickname,
onChangeNickname,
} = this.props;
if (isPublic) {
return null;
}
const disappearingTitle = i18n('disappearingMessages') as any;
const blockTitle = isBlocked ? i18n('unblockUser') : i18n('blockUser');
const blockHandler = isBlocked ? onUnblockUser : onBlockUser;
const disappearingMessagesMenuItem = (
<SubMenu title={disappearingTitle}>
{(timerOptions || []).map(item => (
<MenuItem
key={item.value}
onClick={() => {
onSetDisappearingMessages(item.value);
}}
>
{item.name}
</MenuItem>
))}
</SubMenu>
);
const showMembersMenuItem = isGroup && (
<MenuItem onClick={onShowGroupMembers}>{i18n('showMembers')}</MenuItem>
);
const showSafetyNumberMenuItem = !isGroup &&
!isMe && (
<MenuItem onClick={onShowSafetyNumber}>
{i18n('showSafetyNumber')}
</MenuItem>
);
const resetSessionMenuItem = !isGroup && (
<MenuItem onClick={onResetSession}>{i18n('resetSession')}</MenuItem>
);
const blockHandlerMenuItem = !isMe && (
<MenuItem onClick={blockHandler}>{blockTitle}</MenuItem>
);
const changeNicknameMenuItem = !isMe && (
<MenuItem onClick={onChangeNickname}>{i18n('changeNickname')}</MenuItem>
);
const clearNicknameMenuItem = !isMe &&
hasNickname && (
<MenuItem onClick={onClearNickname}>{i18n('clearNickname')}</MenuItem>
);
const archiveConversationMenuItem = isArchived ? (
<MenuItem onClick={onMoveToInbox}>
{i18n('moveConversationToInbox')}
</MenuItem>
) : (
<MenuItem onClick={onArchive}>{i18n('archiveConversation')}</MenuItem>
);
return (
<React.Fragment>
{/* <MenuItem onClick={onShowAllMedia}>{i18n('viewAllMedia')}</MenuItem> */}
{disappearingMessagesMenuItem}
{showMembersMenuItem}
{showSafetyNumberMenuItem}
{resetSessionMenuItem}
{blockHandlerMenuItem}
{changeNicknameMenuItem}
{clearNicknameMenuItem}
{archiveConversationMenuItem}
</React.Fragment>
);
}
}

@ -45,6 +45,7 @@ export type ConversationType = {
phoneNumber: string;
type: 'direct' | 'group';
isMe: boolean;
isPublic?: boolean;
isClosable?: boolean;
lastUpdated: number;
unreadCount: number;

Loading…
Cancel
Save