make owner delete chat instead of leaving
This commit is contained in:
+33
-3
@@ -61,6 +61,16 @@ const messages = defineMessages({
|
|||||||
defaultMessage: 'Are you sure you want to delete all messages for everyone? It cannot be undone.',
|
defaultMessage: 'Are you sure you want to delete all messages for everyone? It cannot be undone.',
|
||||||
description: 'Alert dialog warning when hard-deleting all messages.'
|
description: 'Alert dialog warning when hard-deleting all messages.'
|
||||||
},
|
},
|
||||||
|
topic_delete: {
|
||||||
|
id: 'topic_delete',
|
||||||
|
defaultMessage: 'Delete Conversation',
|
||||||
|
description: 'Alert title when deleting the topic.'
|
||||||
|
},
|
||||||
|
topic_delete_warning: {
|
||||||
|
id: 'topic_delete_warning',
|
||||||
|
defaultMessage: 'Are you sure you want to delete this conversation? It cannot be undone.',
|
||||||
|
description: 'Alert warning when deleting entire topic'
|
||||||
|
},
|
||||||
leave_chat: {
|
leave_chat: {
|
||||||
id: 'action_leave_chat',
|
id: 'action_leave_chat',
|
||||||
defaultMessage: 'Leave Conversation',
|
defaultMessage: 'Leave Conversation',
|
||||||
@@ -143,6 +153,7 @@ class InfoView extends React.Component {
|
|||||||
this.handleShowAddMembers = this.handleShowAddMembers.bind(this);
|
this.handleShowAddMembers = this.handleShowAddMembers.bind(this);
|
||||||
this.handleHideAddMembers = this.handleHideAddMembers.bind(this);
|
this.handleHideAddMembers = this.handleHideAddMembers.bind(this);
|
||||||
this.handleMemberUpdateRequest = this.handleMemberUpdateRequest.bind(this);
|
this.handleMemberUpdateRequest = this.handleMemberUpdateRequest.bind(this);
|
||||||
|
this.handleDeleteTopic = this.handleDeleteTopic.bind(this);
|
||||||
this.handleDeleteMessages = this.handleDeleteMessages.bind(this);
|
this.handleDeleteMessages = this.handleDeleteMessages.bind(this);
|
||||||
this.handleLeave = this.handleLeave.bind(this);
|
this.handleLeave = this.handleLeave.bind(this);
|
||||||
this.handleBlock = this.handleBlock.bind(this);
|
this.handleBlock = this.handleBlock.bind(this);
|
||||||
@@ -422,6 +433,19 @@ class InfoView extends React.Component {
|
|||||||
this.setState({showMemberPanel: false});
|
this.setState({showMemberPanel: false});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
handleDeleteTopic(e) {
|
||||||
|
e.preventDefault();
|
||||||
|
const {formatMessage} = this.props.intl;
|
||||||
|
this.props.onShowAlert(
|
||||||
|
formatMessage(messages.topic_delete), // title
|
||||||
|
formatMessage(messages.topic_delete_warning), // content
|
||||||
|
(() => { this.props.onDeleteTopic(this.props.topic); }), // onConfirm
|
||||||
|
null, // "OK"
|
||||||
|
true, // Show Reject button
|
||||||
|
null // "Cancel"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
handleDeleteMessages(e) {
|
handleDeleteMessages(e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
const {formatMessage} = this.props.intl;
|
const {formatMessage} = this.props.intl;
|
||||||
@@ -717,9 +741,15 @@ class InfoView extends React.Component {
|
|||||||
:
|
:
|
||||||
null
|
null
|
||||||
}
|
}
|
||||||
<a href="#" className="danger flat-button" onClick={this.handleLeave}>
|
{this.state.owner ?
|
||||||
<i className="material-icons">exit_to_app</i> {formatMessage(messages.leave_chat)}
|
<a href="#" className="danger flat-button" onClick={this.handleDeleteTopic}>
|
||||||
</a>
|
<i className="material-icons">delete</i> {formatMessage(messages.topic_delete)}
|
||||||
|
</a>
|
||||||
|
:
|
||||||
|
<a href="#" className="danger flat-button" onClick={this.handleLeave}>
|
||||||
|
<i className="material-icons">exit_to_app</i> {formatMessage(messages.leave_chat)}
|
||||||
|
</a>
|
||||||
|
}
|
||||||
{!this.state.groupTopic ?
|
{!this.state.groupTopic ?
|
||||||
<a href="#" className="danger flat-button" onClick={this.handleBlock}>
|
<a href="#" className="danger flat-button" onClick={this.handleBlock}>
|
||||||
<i className="material-icons">block</i> {formatMessage(messages.block_contact)}
|
<i className="material-icons">block</i> {formatMessage(messages.block_contact)}
|
||||||
|
|||||||
@@ -123,6 +123,7 @@ class TinodeWeb extends React.Component {
|
|||||||
this.handleTagsUpdated = this.handleTagsUpdated.bind(this);
|
this.handleTagsUpdated = this.handleTagsUpdated.bind(this);
|
||||||
this.handleLogout = this.handleLogout.bind(this);
|
this.handleLogout = this.handleLogout.bind(this);
|
||||||
this.handleDeleteAccount = this.handleDeleteAccount.bind(this);
|
this.handleDeleteAccount = this.handleDeleteAccount.bind(this);
|
||||||
|
this.handleDeleteTopicRequest = this.handleDeleteTopicRequest.bind(this);
|
||||||
this.handleDeleteMessagesRequest = this.handleDeleteMessagesRequest.bind(this);
|
this.handleDeleteMessagesRequest = this.handleDeleteMessagesRequest.bind(this);
|
||||||
this.handleLeaveUnsubRequest = this.handleLeaveUnsubRequest.bind(this);
|
this.handleLeaveUnsubRequest = this.handleLeaveUnsubRequest.bind(this);
|
||||||
this.handleBlockTopicRequest = this.handleBlockTopicRequest.bind(this);
|
this.handleBlockTopicRequest = this.handleBlockTopicRequest.bind(this);
|
||||||
@@ -1290,6 +1291,21 @@ class TinodeWeb extends React.Component {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
handleDeleteTopicRequest(topicName) {
|
||||||
|
const topic = this.tinode.getTopic(topicName);
|
||||||
|
if (!topic) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Request to hard-delete topic.
|
||||||
|
topic.delTopic(true).then((ctrl) => {
|
||||||
|
// Hide MessagesView and InfoView panels.
|
||||||
|
HashNavigation.navigateTo(HashNavigation.setUrlTopic(window.location.hash, ''));
|
||||||
|
}).catch((err) => {
|
||||||
|
this.handleError(err.message, 'err');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
handleDeleteMessagesRequest(topicName) {
|
handleDeleteMessagesRequest(topicName) {
|
||||||
const topic = this.tinode.getTopic(topicName);
|
const topic = this.tinode.getTopic(topicName);
|
||||||
if (!topic) {
|
if (!topic) {
|
||||||
@@ -1655,6 +1671,7 @@ class TinodeWeb extends React.Component {
|
|||||||
onShowAlert={this.handleShowAlert}
|
onShowAlert={this.handleShowAlert}
|
||||||
onChangePermissions={this.handleChangePermissions}
|
onChangePermissions={this.handleChangePermissions}
|
||||||
onMemberUpdateRequest={this.handleMemberUpdateRequest}
|
onMemberUpdateRequest={this.handleMemberUpdateRequest}
|
||||||
|
onDeleteTopic={this.handleDeleteTopicRequest}
|
||||||
onDeleteMessages={this.handleDeleteMessagesRequest}
|
onDeleteMessages={this.handleDeleteMessagesRequest}
|
||||||
onLeaveTopic={this.handleLeaveUnsubRequest}
|
onLeaveTopic={this.handleLeaveUnsubRequest}
|
||||||
onBlockTopic={this.handleBlockTopicRequest}
|
onBlockTopic={this.handleBlockTopicRequest}
|
||||||
|
|||||||
Reference in New Issue
Block a user