Review comments

Conflicts:
	src/ContentMessages.js
This commit is contained in:
Mark Haines 2016-11-08 11:42:20 +00:00
parent 734c4eb638
commit bf5ecbd016
6 changed files with 79 additions and 66 deletions

View file

@ -16,17 +16,14 @@ limitations under the License.
'use strict';
var React = require('react');
var filesize = require('filesize');
import React from 'react';
import MFileBody from './MFileBody';
var MatrixClientPeg = require('../../../MatrixClientPeg');
var ImageUtils = require('../../../ImageUtils');
var Modal = require('../../../Modal');
var sdk = require('../../../index');
var dis = require("../../../dispatcher");
var DecryptFile = require('../../../utils/DecryptFile');
import MatrixClientPeg from '../../../MatrixClientPeg';
import ImageUtils from '../../../ImageUtils';
import Modal from '../../../Modal';
import sdk from '../../../index';
import dis from '../../../dispatcher';
import DecryptFile from '../../../utils/DecryptFile';
module.exports = React.createClass({
displayName: 'MImageBody',
@ -86,7 +83,7 @@ module.exports = React.createClass({
},
_getContentUrl: function() {
var content = this.props.mxEvent.getContent();
const content = this.props.mxEvent.getContent();
if (content.file !== undefined) {
return this.state.decryptedUrl;
} else {
@ -95,7 +92,7 @@ module.exports = React.createClass({
},
_getThumbUrl: function() {
var content = this.props.mxEvent.getContent();
const content = this.props.mxEvent.getContent();
if (content.file !== undefined) {
// TODO: Decrypt and use the thumbnail file if one is present.
return this.state.decryptedUrl;
@ -107,17 +104,16 @@ module.exports = React.createClass({
componentDidMount: function() {
this.dispatcherRef = dis.register(this.onAction);
this.fixupHeight();
var content = this.props.mxEvent.getContent();
var self = this;
const content = this.props.mxEvent.getContent();
if (content.file !== undefined && this.state.decryptedUrl === null) {
DecryptFile.decryptFile(content.file).then(function(url) {
self.setState({
DecryptFile.decryptFile(content.file).done((url) => {
this.setState({
decryptedUrl: url,
});
}).catch(function (err) {
}, (err) => {
console.warn("Unable to decrypt attachment: ", err)
// Set a placeholder image when we can't decrypt the image.
self.refs.image.src = "img/warning.svg";
this.refs.image.src = "img/warning.svg";
});
}
},