isExporting -> forExport and wrap EventTile with Context Provider
This commit is contained in:
parent
9e298e9f45
commit
6f8c1638aa
8 changed files with 55 additions and 53 deletions
|
@ -37,14 +37,14 @@ function getdaysArray() {
|
|||
export default class DateSeparator extends React.Component {
|
||||
static propTypes = {
|
||||
ts: PropTypes.number.isRequired,
|
||||
isExporting: PropTypes.bool,
|
||||
forExport: PropTypes.bool,
|
||||
};
|
||||
|
||||
getLabel() {
|
||||
const date = new Date(this.props.ts);
|
||||
|
||||
// During the time the archive is being viewed, a specific day might not make sense, so we return the full date
|
||||
if (this.props.isExporting) return formatFullDateNoTime(date);
|
||||
if (this.props.forExport) return formatFullDateNoTime(date);
|
||||
|
||||
const today = new Date();
|
||||
const yesterday = new Date();
|
||||
|
|
|
@ -104,7 +104,7 @@ export default class MFileBody extends React.Component {
|
|||
showGenericPlaceholder: PropTypes.bool,
|
||||
/* to set source to local file path during export */
|
||||
mediaSrc: PropTypes.string,
|
||||
isExporting: PropTypes.bool,
|
||||
forExport: PropTypes.bool,
|
||||
};
|
||||
|
||||
static defaultProps = {
|
||||
|
@ -176,7 +176,7 @@ export default class MFileBody extends React.Component {
|
|||
placeholder = (
|
||||
<div className="mx_MFileBody_info">
|
||||
<span className="mx_MFileBody_info_icon" >
|
||||
{this.props.isExporting ?
|
||||
{this.props.forExport ?
|
||||
<img alt="Attachment" className="mx_export_attach_icon" src="icons/attach.svg" />
|
||||
: null}
|
||||
</span>
|
||||
|
|
|
@ -48,7 +48,7 @@ export default class MessageEvent extends React.Component {
|
|||
mediaSrc: PropTypes.string,
|
||||
|
||||
/* to set source to local file path during export */
|
||||
isExporting: PropTypes.bool,
|
||||
forExport: PropTypes.bool,
|
||||
|
||||
/* the maximum image height to use, if the event is an image */
|
||||
maxImageHeight: PropTypes.number,
|
||||
|
@ -127,7 +127,7 @@ export default class MessageEvent extends React.Component {
|
|||
showUrlPreview={this.props.showUrlPreview}
|
||||
tileShape={this.props.tileShape}
|
||||
mediaSrc={this.props.mediaSrc}
|
||||
isExporting={this.props.isExporting}
|
||||
forExport={this.props.forExport}
|
||||
maxImageHeight={this.props.maxImageHeight}
|
||||
replacingEventId={this.props.replacingEventId}
|
||||
editState={this.props.editState}
|
||||
|
|
|
@ -21,17 +21,14 @@ import { _t } from "../../../languageHandler";
|
|||
import MatrixClientContext from "../../../contexts/MatrixClientContext";
|
||||
import { formatFullDate } from "../../../DateUtils";
|
||||
import SettingsStore from "../../../settings/SettingsStore";
|
||||
import { MatrixClientPeg } from "../../../MatrixClientPeg";
|
||||
|
||||
interface IProps {
|
||||
mxEvent: MatrixEvent;
|
||||
isExporting: boolean;
|
||||
forExport: boolean;
|
||||
}
|
||||
|
||||
const RedactedBody = React.forwardRef<any, IProps>(({mxEvent, isExporting}, ref) => {
|
||||
let cli: MatrixClient = useContext(MatrixClientContext);
|
||||
// As context doesn't propagate during export, we'll have to explicitly declare
|
||||
if (isExporting) cli = MatrixClientPeg.get();
|
||||
const RedactedBody = React.forwardRef<any, IProps>(({mxEvent, forExport}, ref) => {
|
||||
const cli: MatrixClient = useContext(MatrixClientContext);
|
||||
let text = _t("Message deleted");
|
||||
const unsigned = mxEvent.getUnsigned();
|
||||
const redactedBecauseUserId = unsigned && unsigned.redacted_because && unsigned.redacted_because.sender;
|
||||
|
@ -47,7 +44,7 @@ const RedactedBody = React.forwardRef<any, IProps>(({mxEvent, isExporting}, ref)
|
|||
|
||||
return (
|
||||
<span className="mx_RedactedBody" ref={ref} title={titleText}>
|
||||
{ isExporting ? <img alt="Redacted" className="mx_export_trash_icon" src="icons/trash.svg" /> : null }
|
||||
{ forExport ? <img alt="Redacted" className="mx_export_trash_icon" src="icons/trash.svg" /> : null }
|
||||
{ text }
|
||||
</span>
|
||||
);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue