diff --git a/app/components/DeleteMessageModal.js b/app/components/DeleteMessageModal.js index 5959cf7..a973803 100644 --- a/app/components/DeleteMessageModal.js +++ b/app/components/DeleteMessageModal.js @@ -1,116 +1,126 @@ import React, { Component } from 'react'; import PropTypes from 'prop-types'; import autoBind from 'auto-bind'; import { View, Platform } from 'react-native'; import UserIcon from './UserIcon'; import { Chip, Dialog, Portal, Text, Button, Surface, TextInput, Paragraph, RadioButton, Checkbox, Switch } from 'react-native-paper'; import KeyboardAwareDialog from './KeyBoardAwareDialog'; const DialogType = Platform.OS === 'ios' ? KeyboardAwareDialog : Dialog; import styles from '../assets/styles/blink/_DeleteMessageModal.scss'; class DeleteMessageModal extends Component { constructor(props) { super(props); autoBind(this); this.state = { uri: this.props.contact ? this.props.contact.uri : null, username: this.props.contact && this.props.contact.uri ? this.props.contact.uri.split('@')[0] : null, displayName: this.props.contact ? this.props.contact.name : null, contact: this.props.contact, show: this.props.show, remoteDelete: true, message: this.props.message, confirm: false, } } UNSAFE_componentWillReceiveProps(nextProps) { this.setState({show: nextProps.show, uri: nextProps.contact ? nextProps.contact.uri : null, username: nextProps.contact && nextProps.contact.uri ? nextProps.contact.uri.split('@')[0] : null, displayName: nextProps.contact ? nextProps.contact.name : null, confirm: nextProps.confirm, contact: nextProps.contact, message: nextProps.message }); } deleteMessage(event) { event.preventDefault(); if (this.state.confirm || true) { let id = this.state.message ? this.state.message._id : 'Unknown'; this.setState({confirm: false, remoteDelete: true}); this.props.deleteMessage(id, this.state.uri, this.state.remoteDelete); this.props.close(); } else { this.setState({confirm: true}); } } toggleRemoteDelete() { this.setState({remoteDelete: !this.state.remoteDelete}) } render() { - let identity = {uri: this.state.uri, displayName: this.state.displayName}; let deleteLabel = this.state.confirm || true ? 'Confirm': 'Delete'; let remote_label = (this.state.displayName && this.state.displayName !== this.state.uri) ? this.state.displayName : this.state.username; + let canDeleteRemote = (this.state.message && this.state.message.direction === 'outgoing' && this.state.uri.indexOf('@videoconference') === -1); + if (this.state.uri && this.state.uri.indexOf('@videoconference') >- -1) { + canDeleteRemote = false; + } return ( {'Delete message'} Are you sure you want to delete this message? - {Platform.OS === 'ios' ? + {Platform.OS === 'ios' && canDeleteRemote ? this.toggleRemoteDelete()}/> - : + : null + } + {Platform.OS === 'android' && canDeleteRemote ? {this.toggleRemoteDelete()}}/> + : null } + + {canDeleteRemote ? Also delete for {remote_label} + : null} + ); } } DeleteMessageModal.propTypes = { show : PropTypes.bool, close : PropTypes.func.isRequired, contact : PropTypes.object, deleteMessage : PropTypes.func, message : PropTypes.object }; export default DeleteMessageModal;