diff --git a/.eslintignore.errorfiles b/.eslintignore.errorfiles index 3b2e7bbb43..e7f6ee1f84 100644 --- a/.eslintignore.errorfiles +++ b/.eslintignore.errorfiles @@ -17,7 +17,6 @@ src/components/views/dialogs/SetPasswordDialog.js src/components/views/dialogs/UnknownDeviceDialog.js src/components/views/elements/AddressSelector.js src/components/views/elements/DirectorySearchBox.js -src/components/views/elements/ImageView.js src/components/views/elements/MemberEventListSummary.js src/components/views/elements/TintableSvg.js src/components/views/elements/UserSelector.js diff --git a/src/components/views/elements/ImageView.js b/src/components/views/elements/ImageView.js index 9a47bce553..c65de6b22e 100644 --- a/src/components/views/elements/ImageView.js +++ b/src/components/views/elements/ImageView.js @@ -1,5 +1,6 @@ /* Copyright 2015, 2016 OpenMarket Ltd +Copyright 2019 Michael Telatynski <7t3chguy@gmail.com> Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -60,7 +61,7 @@ export default class ImageView extends React.Component { } onKeyDown = (ev) => { - if (ev.keyCode == 27) { // escape + if (ev.keyCode === 27) { // escape ev.stopPropagation(); ev.preventDefault(); this.props.onFinished(); @@ -72,7 +73,6 @@ export default class ImageView extends React.Component { Modal.createTrackedDialog('Confirm Redact Dialog', 'Image View', ConfirmRedactDialog, { onFinished: (proceed) => { if (!proceed) return; - const self = this; MatrixClientPeg.get().redactEvent( this.props.mxEvent.getRoomId(), this.props.mxEvent.getId(), ).catch(function(e) { @@ -153,32 +153,38 @@ export default class ImageView extends React.Component { size = filesize(this.props.fileSize); } - let size_res; + let sizeRes; if (size && res) { - size_res = size + ", " + res; + sizeRes = size + ", " + res; } else { - size_res = size || res; + sizeRes = size || res; } + let mayRedact = false; const showEventMeta = !!this.props.mxEvent; let eventMeta; if (showEventMeta) { // Figure out the sender, defaulting to mxid let sender = this.props.mxEvent.getSender(); - const room = MatrixClientPeg.get().getRoom(this.props.mxEvent.getRoomId()); + const cli = MatrixClientPeg.get(); + const room = cli.getRoom(this.props.mxEvent.getRoomId()); if (room) { + mayRedact = room.currentState.maySendRedactionForEvent(this.props.mxEvent, cli.credentials.userId); const member = room.getMember(sender); if (member) sender = member.name; } eventMeta = (
- { _t('Uploaded on %(date)s by %(user)s', {date: formatDate(new Date(this.props.mxEvent.getTs())), user: sender}) } + { _t('Uploaded on %(date)s by %(user)s', { + date: formatDate(new Date(this.props.mxEvent.getTs())), + user: sender, + }) }
); } let eventRedact; - if (showEventMeta) { + if (mayRedact) { eventRedact = (
{ _t('Remove') }
); @@ -213,7 +219,7 @@ export default class ImageView extends React.Component {
{ _t('Download this file') }
- { size_res } + { sizeRes }
{ eventRedact }