2017-11-24 20:44:52 +00:00
|
|
|
import React from 'react';
|
|
|
|
import PropTypes from 'prop-types';
|
2019-02-27 14:47:15 +00:00
|
|
|
import { Alert, Clipboard, Share } from 'react-native';
|
2017-11-24 20:44:52 +00:00
|
|
|
import { connect } from 'react-redux';
|
2019-01-30 12:11:02 +00:00
|
|
|
import ActionSheet from 'react-native-action-sheet';
|
2019-05-31 14:42:54 +00:00
|
|
|
import moment from 'moment';
|
2019-06-28 17:07:17 +00:00
|
|
|
import * as Haptics from 'expo-haptics';
|
|
|
|
|
2018-03-29 17:55:37 +00:00
|
|
|
import RocketChat from '../lib/rocketchat';
|
2019-09-16 20:26:32 +00:00
|
|
|
import database from '../lib/database';
|
2018-06-01 17:38:13 +00:00
|
|
|
import I18n from '../i18n';
|
2019-05-16 13:40:50 +00:00
|
|
|
import log from '../utils/log';
|
2019-06-10 18:36:31 +00:00
|
|
|
import Navigation from '../lib/Navigation';
|
2019-06-28 17:02:30 +00:00
|
|
|
import { getMessageTranslation } from './message/utils';
|
2019-07-23 14:02:57 +00:00
|
|
|
import { LISTENER } from './Toast';
|
|
|
|
import EventEmitter from '../utils/events';
|
2020-02-10 14:53:42 +00:00
|
|
|
import { showConfirmationAlert } from '../utils/info';
|
2017-11-24 20:44:52 +00:00
|
|
|
|
2019-08-07 13:51:34 +00:00
|
|
|
class MessageActions extends React.Component {
|
2017-11-24 20:44:52 +00:00
|
|
|
static propTypes = {
|
|
|
|
actionsHide: PropTypes.func.isRequired,
|
2018-07-10 13:40:32 +00:00
|
|
|
room: PropTypes.object.isRequired,
|
2019-09-16 20:26:32 +00:00
|
|
|
message: PropTypes.object,
|
2019-06-28 17:02:30 +00:00
|
|
|
user: PropTypes.object,
|
2017-11-24 20:44:52 +00:00
|
|
|
editInit: PropTypes.func.isRequired,
|
2019-09-16 20:26:32 +00:00
|
|
|
reactionInit: PropTypes.func.isRequired,
|
2018-07-20 19:54:46 +00:00
|
|
|
replyInit: PropTypes.func.isRequired,
|
2019-09-16 20:26:32 +00:00
|
|
|
isReadOnly: PropTypes.bool,
|
2017-11-24 20:44:52 +00:00
|
|
|
Message_AllowDeleting: PropTypes.bool,
|
|
|
|
Message_AllowDeleting_BlockDeleteInMinutes: PropTypes.number,
|
|
|
|
Message_AllowEditing: PropTypes.bool,
|
|
|
|
Message_AllowEditing_BlockEditInMinutes: PropTypes.number,
|
|
|
|
Message_AllowPinning: PropTypes.bool,
|
2019-06-10 18:36:31 +00:00
|
|
|
Message_AllowStarring: PropTypes.bool,
|
2020-06-15 14:00:46 +00:00
|
|
|
Message_Read_Receipt_Store_Users: PropTypes.bool,
|
|
|
|
isMasterDetail: PropTypes.bool
|
2017-11-24 20:44:52 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
constructor(props) {
|
|
|
|
super(props);
|
|
|
|
this.handleActionPress = this.handleActionPress.bind(this);
|
2019-09-16 20:26:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
async componentDidMount() {
|
|
|
|
await this.setPermissions();
|
2017-11-24 20:44:52 +00:00
|
|
|
|
2019-09-16 20:26:32 +00:00
|
|
|
const {
|
|
|
|
Message_AllowStarring, Message_AllowPinning, Message_Read_Receipt_Store_Users, user, room, message, isReadOnly
|
|
|
|
} = this.props;
|
2018-09-25 19:28:42 +00:00
|
|
|
|
2018-06-18 13:30:36 +00:00
|
|
|
// Cancel
|
|
|
|
this.options = [I18n.t('Cancel')];
|
|
|
|
this.CANCEL_INDEX = 0;
|
|
|
|
|
|
|
|
// Reply
|
2019-09-16 20:26:32 +00:00
|
|
|
if (!isReadOnly) {
|
2018-06-18 13:30:36 +00:00
|
|
|
this.options.push(I18n.t('Reply'));
|
|
|
|
this.REPLY_INDEX = this.options.length - 1;
|
2017-11-24 20:44:52 +00:00
|
|
|
}
|
|
|
|
|
2018-06-18 13:30:36 +00:00
|
|
|
// Edit
|
2019-09-16 20:26:32 +00:00
|
|
|
if (this.allowEdit(this.props)) {
|
2018-06-18 13:30:36 +00:00
|
|
|
this.options.push(I18n.t('Edit'));
|
|
|
|
this.EDIT_INDEX = this.options.length - 1;
|
|
|
|
}
|
|
|
|
|
2020-03-30 19:50:27 +00:00
|
|
|
// Create Discussion
|
|
|
|
this.options.push(I18n.t('Create_Discussion'));
|
|
|
|
this.CREATE_DISCUSSION_INDEX = this.options.length - 1;
|
|
|
|
|
2020-02-28 19:31:19 +00:00
|
|
|
// Mark as unread
|
|
|
|
if (message.u && message.u._id !== user.id) {
|
|
|
|
this.options.push(I18n.t('Mark_unread'));
|
|
|
|
this.UNREAD_INDEX = this.options.length - 1;
|
|
|
|
}
|
|
|
|
|
2018-06-18 13:30:36 +00:00
|
|
|
// Permalink
|
2019-02-26 12:45:45 +00:00
|
|
|
this.options.push(I18n.t('Permalink'));
|
2018-06-18 13:30:36 +00:00
|
|
|
this.PERMALINK_INDEX = this.options.length - 1;
|
|
|
|
|
|
|
|
// Copy
|
2019-02-26 12:45:45 +00:00
|
|
|
this.options.push(I18n.t('Copy'));
|
2018-06-18 13:30:36 +00:00
|
|
|
this.COPY_INDEX = this.options.length - 1;
|
|
|
|
|
|
|
|
// Share
|
2019-02-26 12:45:45 +00:00
|
|
|
this.options.push(I18n.t('Share'));
|
2018-06-18 13:30:36 +00:00
|
|
|
this.SHARE_INDEX = this.options.length - 1;
|
|
|
|
|
|
|
|
// Quote
|
2019-09-16 20:26:32 +00:00
|
|
|
if (!isReadOnly) {
|
2018-06-18 13:30:36 +00:00
|
|
|
this.options.push(I18n.t('Quote'));
|
|
|
|
this.QUOTE_INDEX = this.options.length - 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Star
|
2018-09-25 19:28:42 +00:00
|
|
|
if (Message_AllowStarring) {
|
2019-09-16 20:26:32 +00:00
|
|
|
this.options.push(I18n.t(message.starred ? 'Unstar' : 'Star'));
|
2018-06-18 13:30:36 +00:00
|
|
|
this.STAR_INDEX = this.options.length - 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Pin
|
2018-09-25 19:28:42 +00:00
|
|
|
if (Message_AllowPinning) {
|
2019-09-16 20:26:32 +00:00
|
|
|
this.options.push(I18n.t(message.pinned ? 'Unpin' : 'Pin'));
|
2018-06-18 13:30:36 +00:00
|
|
|
this.PIN_INDEX = this.options.length - 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Reaction
|
2019-09-16 20:26:32 +00:00
|
|
|
if (!isReadOnly || this.canReactWhenReadOnly()) {
|
2018-06-18 13:30:36 +00:00
|
|
|
this.options.push(I18n.t('Add_Reaction'));
|
|
|
|
this.REACTION_INDEX = this.options.length - 1;
|
|
|
|
}
|
|
|
|
|
2019-06-10 18:36:31 +00:00
|
|
|
// Read Receipts
|
|
|
|
if (Message_Read_Receipt_Store_Users) {
|
|
|
|
this.options.push(I18n.t('Read_Receipt'));
|
|
|
|
this.READ_RECEIPT_INDEX = this.options.length - 1;
|
|
|
|
}
|
|
|
|
|
2019-06-28 17:02:30 +00:00
|
|
|
// Toggle Auto-translate
|
2019-09-16 20:26:32 +00:00
|
|
|
if (room.autoTranslate && message.u && message.u._id !== user.id) {
|
|
|
|
this.options.push(I18n.t(message.autoTranslate ? 'View_Original' : 'Translate'));
|
2019-06-28 17:02:30 +00:00
|
|
|
this.TOGGLE_TRANSLATION_INDEX = this.options.length - 1;
|
|
|
|
}
|
|
|
|
|
2019-05-16 13:40:50 +00:00
|
|
|
// Report
|
|
|
|
this.options.push(I18n.t('Report'));
|
|
|
|
this.REPORT_INDEX = this.options.length - 1;
|
|
|
|
|
2018-06-18 13:30:36 +00:00
|
|
|
// Delete
|
2019-09-16 20:26:32 +00:00
|
|
|
if (this.allowDelete(this.props)) {
|
2018-06-18 13:30:36 +00:00
|
|
|
this.options.push(I18n.t('Delete'));
|
|
|
|
this.DELETE_INDEX = this.options.length - 1;
|
|
|
|
}
|
|
|
|
setTimeout(() => {
|
2019-01-30 12:11:02 +00:00
|
|
|
this.showActionSheet();
|
2019-06-28 17:07:17 +00:00
|
|
|
Haptics.impactAsync(Haptics.ImpactFeedbackStyle.Light);
|
2018-06-18 13:30:36 +00:00
|
|
|
});
|
2017-11-24 20:44:52 +00:00
|
|
|
}
|
|
|
|
|
2019-09-16 20:26:32 +00:00
|
|
|
async setPermissions() {
|
|
|
|
try {
|
|
|
|
const { room } = this.props;
|
|
|
|
const permissions = ['edit-message', 'delete-message', 'force-delete-message'];
|
|
|
|
const result = await RocketChat.hasPermission(permissions, room.rid);
|
|
|
|
this.hasEditPermission = result[permissions[0]];
|
|
|
|
this.hasDeletePermission = result[permissions[1]];
|
|
|
|
this.hasForceDeletePermission = result[permissions[2]];
|
|
|
|
} catch (e) {
|
|
|
|
log(e);
|
|
|
|
}
|
|
|
|
Promise.resolve();
|
2017-11-24 20:44:52 +00:00
|
|
|
}
|
|
|
|
|
2019-01-30 12:11:02 +00:00
|
|
|
showActionSheet = () => {
|
|
|
|
ActionSheet.showActionSheetWithOptions({
|
|
|
|
options: this.options,
|
|
|
|
cancelButtonIndex: this.CANCEL_INDEX,
|
|
|
|
destructiveButtonIndex: this.DELETE_INDEX,
|
|
|
|
title: I18n.t('Message_actions')
|
|
|
|
}, (actionIndex) => {
|
|
|
|
this.handleActionPress(actionIndex);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2018-06-18 13:30:36 +00:00
|
|
|
getPermalink = async(message) => {
|
|
|
|
try {
|
2019-05-29 21:19:12 +00:00
|
|
|
return await RocketChat.getPermalinkMessage(message);
|
2018-06-18 13:30:36 +00:00
|
|
|
} catch (error) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-09-16 20:26:32 +00:00
|
|
|
isOwn = props => props.message.u && props.message.u._id === props.user.id;
|
2018-01-17 16:42:30 +00:00
|
|
|
|
2018-09-25 19:28:42 +00:00
|
|
|
canReactWhenReadOnly = () => {
|
|
|
|
const { room } = this.props;
|
|
|
|
return room.reactWhenReadOnly;
|
|
|
|
}
|
2018-03-29 17:55:37 +00:00
|
|
|
|
2017-11-24 20:44:52 +00:00
|
|
|
allowEdit = (props) => {
|
2019-09-16 20:26:32 +00:00
|
|
|
if (props.isReadOnly) {
|
2018-01-17 16:42:30 +00:00
|
|
|
return false;
|
|
|
|
}
|
2017-11-24 20:44:52 +00:00
|
|
|
const editOwn = this.isOwn(props);
|
2018-09-25 19:28:42 +00:00
|
|
|
const { Message_AllowEditing: isEditAllowed, Message_AllowEditing_BlockEditInMinutes } = this.props;
|
|
|
|
|
2017-11-24 20:44:52 +00:00
|
|
|
if (!(this.hasEditPermission || (isEditAllowed && editOwn))) {
|
|
|
|
return false;
|
|
|
|
}
|
2018-09-25 19:28:42 +00:00
|
|
|
const blockEditInMinutes = Message_AllowEditing_BlockEditInMinutes;
|
2017-11-24 20:44:52 +00:00
|
|
|
if (blockEditInMinutes) {
|
|
|
|
let msgTs;
|
2019-09-16 20:26:32 +00:00
|
|
|
if (props.message.ts != null) {
|
|
|
|
msgTs = moment(props.message.ts);
|
2017-11-24 20:44:52 +00:00
|
|
|
}
|
|
|
|
let currentTsDiff;
|
|
|
|
if (msgTs != null) {
|
|
|
|
currentTsDiff = moment().diff(msgTs, 'minutes');
|
|
|
|
}
|
|
|
|
return currentTsDiff < blockEditInMinutes;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
allowDelete = (props) => {
|
2019-09-16 20:26:32 +00:00
|
|
|
if (props.isReadOnly) {
|
2018-01-17 16:42:30 +00:00
|
|
|
return false;
|
|
|
|
}
|
2019-05-03 13:33:38 +00:00
|
|
|
|
|
|
|
// Prevent from deleting thread start message when positioned inside the thread
|
2019-09-16 20:26:32 +00:00
|
|
|
if (props.tmid && props.tmid === props.message.id) {
|
2019-05-03 13:33:38 +00:00
|
|
|
return false;
|
|
|
|
}
|
2017-11-24 20:44:52 +00:00
|
|
|
const deleteOwn = this.isOwn(props);
|
2018-09-25 19:28:42 +00:00
|
|
|
const { Message_AllowDeleting: isDeleteAllowed, Message_AllowDeleting_BlockDeleteInMinutes } = this.props;
|
2017-11-24 20:44:52 +00:00
|
|
|
if (!(this.hasDeletePermission || (isDeleteAllowed && deleteOwn) || this.hasForceDeletePermission)) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if (this.hasForceDeletePermission) {
|
|
|
|
return true;
|
|
|
|
}
|
2018-09-25 19:28:42 +00:00
|
|
|
const blockDeleteInMinutes = Message_AllowDeleting_BlockDeleteInMinutes;
|
2017-11-24 20:44:52 +00:00
|
|
|
if (blockDeleteInMinutes != null && blockDeleteInMinutes !== 0) {
|
|
|
|
let msgTs;
|
2019-09-16 20:26:32 +00:00
|
|
|
if (props.message.ts != null) {
|
|
|
|
msgTs = moment(props.message.ts);
|
2017-11-24 20:44:52 +00:00
|
|
|
}
|
|
|
|
let currentTsDiff;
|
|
|
|
if (msgTs != null) {
|
|
|
|
currentTsDiff = moment().diff(msgTs, 'minutes');
|
|
|
|
}
|
|
|
|
return currentTsDiff < blockDeleteInMinutes;
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2018-09-25 19:28:42 +00:00
|
|
|
handleDelete = () => {
|
2020-02-10 14:53:42 +00:00
|
|
|
showConfirmationAlert({
|
|
|
|
message: I18n.t('You_will_not_be_able_to_recover_this_message'),
|
|
|
|
callToAction: I18n.t('Delete'),
|
|
|
|
onPress: async() => {
|
|
|
|
const { message } = this.props;
|
|
|
|
try {
|
|
|
|
await RocketChat.deleteMessage(message.id, message.subscription.id);
|
|
|
|
} catch (e) {
|
|
|
|
log(e);
|
2017-11-24 20:44:52 +00:00
|
|
|
}
|
2020-02-10 14:53:42 +00:00
|
|
|
}
|
|
|
|
});
|
2017-11-24 20:44:52 +00:00
|
|
|
}
|
|
|
|
|
2018-09-25 19:28:42 +00:00
|
|
|
handleEdit = () => {
|
2019-09-16 20:26:32 +00:00
|
|
|
const { message, editInit } = this.props;
|
|
|
|
editInit(message);
|
2017-11-24 20:44:52 +00:00
|
|
|
}
|
|
|
|
|
2020-02-28 19:31:19 +00:00
|
|
|
handleUnread = async() => {
|
2020-06-15 14:00:46 +00:00
|
|
|
const { message, room, isMasterDetail } = this.props;
|
2020-02-28 19:31:19 +00:00
|
|
|
const { id: messageId, ts } = message;
|
|
|
|
const { rid } = room;
|
|
|
|
try {
|
|
|
|
const db = database.active;
|
|
|
|
const result = await RocketChat.markAsUnread({ messageId });
|
|
|
|
if (result.success) {
|
|
|
|
const subCollection = db.collections.get('subscriptions');
|
|
|
|
const subRecord = await subCollection.find(rid);
|
|
|
|
await db.action(async() => {
|
|
|
|
try {
|
|
|
|
await subRecord.update(sub => sub.lastOpen = ts);
|
|
|
|
} catch {
|
|
|
|
// do nothing
|
|
|
|
}
|
|
|
|
});
|
2020-06-15 14:00:46 +00:00
|
|
|
if (isMasterDetail) {
|
|
|
|
Navigation.replace('RoomView');
|
|
|
|
} else {
|
|
|
|
Navigation.navigate('RoomsListView');
|
|
|
|
}
|
2020-02-28 19:31:19 +00:00
|
|
|
}
|
|
|
|
} catch (e) {
|
|
|
|
log(e);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-11-24 20:44:52 +00:00
|
|
|
handleCopy = async() => {
|
2019-09-16 20:26:32 +00:00
|
|
|
const { message } = this.props;
|
|
|
|
await Clipboard.setString(message.msg);
|
2019-07-23 14:02:57 +00:00
|
|
|
EventEmitter.emit(LISTENER, { message: I18n.t('Copied_to_clipboard') });
|
2017-11-24 20:44:52 +00:00
|
|
|
}
|
|
|
|
|
2018-12-05 20:52:08 +00:00
|
|
|
handleShare = async() => {
|
2019-09-16 20:26:32 +00:00
|
|
|
const { message } = this.props;
|
|
|
|
const permalink = await this.getPermalink(message);
|
2020-02-05 16:40:44 +00:00
|
|
|
if (!permalink) {
|
|
|
|
return;
|
|
|
|
}
|
2018-02-01 12:48:58 +00:00
|
|
|
Share.share({
|
2018-12-05 20:52:08 +00:00
|
|
|
message: permalink
|
2018-02-01 12:48:58 +00:00
|
|
|
});
|
|
|
|
};
|
|
|
|
|
2019-09-16 20:26:32 +00:00
|
|
|
handleStar = async() => {
|
|
|
|
const { message } = this.props;
|
|
|
|
try {
|
|
|
|
await RocketChat.toggleStarMessage(message.id, message.starred);
|
2020-03-17 16:35:37 +00:00
|
|
|
EventEmitter.emit(LISTENER, { message: message.starred ? I18n.t('Message_unstarred') : I18n.t('Message_starred') });
|
2019-09-16 20:26:32 +00:00
|
|
|
} catch (e) {
|
|
|
|
log(e);
|
|
|
|
}
|
2017-11-24 20:44:52 +00:00
|
|
|
}
|
|
|
|
|
2018-09-25 19:28:42 +00:00
|
|
|
handlePermalink = async() => {
|
2019-09-16 20:26:32 +00:00
|
|
|
const { message } = this.props;
|
|
|
|
const permalink = await this.getPermalink(message);
|
2018-06-18 13:30:36 +00:00
|
|
|
Clipboard.setString(permalink);
|
2019-07-23 14:02:57 +00:00
|
|
|
EventEmitter.emit(LISTENER, { message: I18n.t('Permalink_copied_to_clipboard') });
|
2017-11-24 20:44:52 +00:00
|
|
|
}
|
|
|
|
|
2019-09-16 20:26:32 +00:00
|
|
|
handlePin = async() => {
|
|
|
|
const { message } = this.props;
|
|
|
|
try {
|
|
|
|
await RocketChat.togglePinMessage(message.id, message.pinned);
|
|
|
|
} catch (e) {
|
|
|
|
log(e);
|
|
|
|
}
|
2017-11-24 20:44:52 +00:00
|
|
|
}
|
|
|
|
|
2018-09-25 19:28:42 +00:00
|
|
|
handleReply = () => {
|
2019-09-16 20:26:32 +00:00
|
|
|
const { message, replyInit } = this.props;
|
|
|
|
replyInit(message, true);
|
2017-11-24 20:44:52 +00:00
|
|
|
}
|
|
|
|
|
2018-09-25 19:28:42 +00:00
|
|
|
handleQuote = () => {
|
2019-09-16 20:26:32 +00:00
|
|
|
const { message, replyInit } = this.props;
|
|
|
|
replyInit(message, false);
|
2017-11-24 20:44:52 +00:00
|
|
|
}
|
|
|
|
|
2018-09-25 19:28:42 +00:00
|
|
|
handleReaction = () => {
|
2019-09-16 20:26:32 +00:00
|
|
|
const { message, reactionInit } = this.props;
|
|
|
|
reactionInit(message);
|
2018-01-30 19:48:26 +00:00
|
|
|
}
|
|
|
|
|
2019-06-10 18:36:31 +00:00
|
|
|
handleReadReceipt = () => {
|
2019-09-16 20:26:32 +00:00
|
|
|
const { message } = this.props;
|
|
|
|
Navigation.navigate('ReadReceiptsView', { messageId: message.id });
|
2019-06-10 18:36:31 +00:00
|
|
|
}
|
|
|
|
|
2019-05-16 13:40:50 +00:00
|
|
|
handleReport = async() => {
|
2019-09-16 20:26:32 +00:00
|
|
|
const { message } = this.props;
|
2019-05-16 13:40:50 +00:00
|
|
|
try {
|
2019-09-16 20:26:32 +00:00
|
|
|
await RocketChat.reportMessage(message.id);
|
2019-05-16 13:40:50 +00:00
|
|
|
Alert.alert(I18n.t('Message_Reported'));
|
2019-08-30 12:43:23 +00:00
|
|
|
} catch (e) {
|
|
|
|
log(e);
|
2019-05-16 13:40:50 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-06-28 17:02:30 +00:00
|
|
|
handleToggleTranslation = async() => {
|
2019-09-16 20:26:32 +00:00
|
|
|
const { message, room } = this.props;
|
2019-06-28 17:02:30 +00:00
|
|
|
try {
|
2019-09-16 20:26:32 +00:00
|
|
|
const db = database.active;
|
|
|
|
await db.action(async() => {
|
|
|
|
await message.update((m) => {
|
|
|
|
m.autoTranslate = !m.autoTranslate;
|
|
|
|
m._updatedAt = new Date();
|
|
|
|
});
|
2019-06-28 17:02:30 +00:00
|
|
|
});
|
|
|
|
const translatedMessage = getMessageTranslation(message, room.autoTranslateLanguage);
|
|
|
|
if (!translatedMessage) {
|
2019-09-16 20:26:32 +00:00
|
|
|
const m = {
|
|
|
|
_id: message.id,
|
|
|
|
rid: message.subscription.id,
|
|
|
|
u: message.u,
|
|
|
|
msg: message.msg
|
|
|
|
};
|
|
|
|
await RocketChat.translateMessage(m, room.autoTranslateLanguage);
|
2019-06-28 17:02:30 +00:00
|
|
|
}
|
2019-08-30 12:43:23 +00:00
|
|
|
} catch (e) {
|
|
|
|
log(e);
|
2019-06-28 17:02:30 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-03-30 19:50:27 +00:00
|
|
|
handleCreateDiscussion = () => {
|
2020-06-15 14:00:46 +00:00
|
|
|
const { message, room: channel, isMasterDetail } = this.props;
|
|
|
|
const params = { message, channel, showCloseModal: true };
|
|
|
|
if (isMasterDetail) {
|
|
|
|
Navigation.navigate('ModalStackNavigator', { screen: 'CreateDiscussionView', params });
|
|
|
|
} else {
|
|
|
|
Navigation.navigate('NewMessageStackNavigator', { screen: 'CreateDiscussionView', params });
|
|
|
|
}
|
2020-03-30 19:50:27 +00:00
|
|
|
}
|
|
|
|
|
2017-11-24 20:44:52 +00:00
|
|
|
handleActionPress = (actionIndex) => {
|
2019-01-30 13:33:48 +00:00
|
|
|
if (actionIndex) {
|
|
|
|
switch (actionIndex) {
|
|
|
|
case this.REPLY_INDEX:
|
|
|
|
this.handleReply();
|
|
|
|
break;
|
|
|
|
case this.EDIT_INDEX:
|
|
|
|
this.handleEdit();
|
|
|
|
break;
|
2020-02-28 19:31:19 +00:00
|
|
|
case this.UNREAD_INDEX:
|
|
|
|
this.handleUnread();
|
|
|
|
break;
|
2019-01-30 13:33:48 +00:00
|
|
|
case this.PERMALINK_INDEX:
|
|
|
|
this.handlePermalink();
|
|
|
|
break;
|
|
|
|
case this.COPY_INDEX:
|
|
|
|
this.handleCopy();
|
|
|
|
break;
|
|
|
|
case this.SHARE_INDEX:
|
|
|
|
this.handleShare();
|
|
|
|
break;
|
|
|
|
case this.QUOTE_INDEX:
|
|
|
|
this.handleQuote();
|
|
|
|
break;
|
|
|
|
case this.STAR_INDEX:
|
|
|
|
this.handleStar();
|
|
|
|
break;
|
|
|
|
case this.PIN_INDEX:
|
|
|
|
this.handlePin();
|
|
|
|
break;
|
|
|
|
case this.REACTION_INDEX:
|
|
|
|
this.handleReaction();
|
|
|
|
break;
|
2019-05-16 13:40:50 +00:00
|
|
|
case this.REPORT_INDEX:
|
|
|
|
this.handleReport();
|
|
|
|
break;
|
2019-01-30 13:33:48 +00:00
|
|
|
case this.DELETE_INDEX:
|
|
|
|
this.handleDelete();
|
|
|
|
break;
|
2019-06-10 18:36:31 +00:00
|
|
|
case this.READ_RECEIPT_INDEX:
|
|
|
|
this.handleReadReceipt();
|
|
|
|
break;
|
2020-03-30 19:50:27 +00:00
|
|
|
case this.CREATE_DISCUSSION_INDEX:
|
|
|
|
this.handleCreateDiscussion();
|
|
|
|
break;
|
2019-06-28 17:02:30 +00:00
|
|
|
case this.TOGGLE_TRANSLATION_INDEX:
|
|
|
|
this.handleToggleTranslation();
|
|
|
|
break;
|
2019-01-30 13:33:48 +00:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2017-11-24 20:44:52 +00:00
|
|
|
}
|
2019-01-30 13:33:48 +00:00
|
|
|
const { actionsHide } = this.props;
|
2018-09-25 19:28:42 +00:00
|
|
|
actionsHide();
|
2017-11-24 20:44:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
render() {
|
|
|
|
return (
|
2019-01-30 12:11:02 +00:00
|
|
|
null
|
2017-11-24 20:44:52 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
2019-08-07 13:51:34 +00:00
|
|
|
|
|
|
|
const mapStateToProps = state => ({
|
|
|
|
Message_AllowDeleting: state.settings.Message_AllowDeleting,
|
|
|
|
Message_AllowDeleting_BlockDeleteInMinutes: state.settings.Message_AllowDeleting_BlockDeleteInMinutes,
|
|
|
|
Message_AllowEditing: state.settings.Message_AllowEditing,
|
|
|
|
Message_AllowEditing_BlockEditInMinutes: state.settings.Message_AllowEditing_BlockEditInMinutes,
|
|
|
|
Message_AllowPinning: state.settings.Message_AllowPinning,
|
|
|
|
Message_AllowStarring: state.settings.Message_AllowStarring,
|
2020-06-15 14:00:46 +00:00
|
|
|
Message_Read_Receipt_Store_Users: state.settings.Message_Read_Receipt_Store_Users,
|
|
|
|
isMasterDetail: state.app.isMasterDetail
|
2019-08-07 13:51:34 +00:00
|
|
|
});
|
|
|
|
|
2019-09-16 20:26:32 +00:00
|
|
|
export default connect(mapStateToProps)(MessageActions);
|