Make imports more consistent, fix m.video
This commit is contained in:
parent
bf5ecbd016
commit
9edfea3b32
3 changed files with 29 additions and 30 deletions
|
@ -16,11 +16,11 @@ limitations under the License.
|
||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var React = require('react');
|
import React from 'react';
|
||||||
var filesize = require('filesize');
|
import filesize from 'filesize';
|
||||||
var MatrixClientPeg = require('../../../MatrixClientPeg');
|
import MatrixClientPeg from '../../../MatrixClientPeg';
|
||||||
var sdk = require('../../../index');
|
import sdk from '../../../index';
|
||||||
var DecryptFile = require('../../../utils/DecryptFile');
|
import {decryptFile} from '../../../utils/DecryptFile';
|
||||||
|
|
||||||
|
|
||||||
module.exports = React.createClass({
|
module.exports = React.createClass({
|
||||||
|
@ -66,7 +66,7 @@ module.exports = React.createClass({
|
||||||
componentDidMount: function() {
|
componentDidMount: function() {
|
||||||
const content = this.props.mxEvent.getContent();
|
const content = this.props.mxEvent.getContent();
|
||||||
if (content.file !== undefined && this.state.decryptedUrl === null) {
|
if (content.file !== undefined && this.state.decryptedUrl === null) {
|
||||||
DecryptFile.decryptFile(content.file).done((url) => {
|
decryptFile(content.file).done((url) => {
|
||||||
this.setState({
|
this.setState({
|
||||||
decryptedUrl: url,
|
decryptedUrl: url,
|
||||||
});
|
});
|
||||||
|
|
|
@ -23,7 +23,7 @@ import ImageUtils from '../../../ImageUtils';
|
||||||
import Modal from '../../../Modal';
|
import Modal from '../../../Modal';
|
||||||
import sdk from '../../../index';
|
import sdk from '../../../index';
|
||||||
import dis from '../../../dispatcher';
|
import dis from '../../../dispatcher';
|
||||||
import DecryptFile from '../../../utils/DecryptFile';
|
import {decryptFile} from '../../../utils/DecryptFile';
|
||||||
|
|
||||||
module.exports = React.createClass({
|
module.exports = React.createClass({
|
||||||
displayName: 'MImageBody',
|
displayName: 'MImageBody',
|
||||||
|
@ -43,10 +43,10 @@ module.exports = React.createClass({
|
||||||
onClick: function onClick(ev) {
|
onClick: function onClick(ev) {
|
||||||
if (ev.button == 0 && !ev.metaKey) {
|
if (ev.button == 0 && !ev.metaKey) {
|
||||||
ev.preventDefault();
|
ev.preventDefault();
|
||||||
var content = this.props.mxEvent.getContent();
|
const content = this.props.mxEvent.getContent();
|
||||||
var httpUrl = this._getContentUrl();
|
const httpUrl = this._getContentUrl();
|
||||||
var ImageView = sdk.getComponent("elements.ImageView");
|
const ImageView = sdk.getComponent("elements.ImageView");
|
||||||
var params = {
|
const params = {
|
||||||
src: httpUrl,
|
src: httpUrl,
|
||||||
mxEvent: this.props.mxEvent
|
mxEvent: this.props.mxEvent
|
||||||
};
|
};
|
||||||
|
@ -62,7 +62,7 @@ module.exports = React.createClass({
|
||||||
},
|
},
|
||||||
|
|
||||||
_isGif: function() {
|
_isGif: function() {
|
||||||
var content = this.props.mxEvent.getContent();
|
const content = this.props.mxEvent.getContent();
|
||||||
return (content && content.info && content.info.mimetype === "image/gif");
|
return (content && content.info && content.info.mimetype === "image/gif");
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -106,7 +106,7 @@ module.exports = React.createClass({
|
||||||
this.fixupHeight();
|
this.fixupHeight();
|
||||||
const content = this.props.mxEvent.getContent();
|
const content = this.props.mxEvent.getContent();
|
||||||
if (content.file !== undefined && this.state.decryptedUrl === null) {
|
if (content.file !== undefined && this.state.decryptedUrl === null) {
|
||||||
DecryptFile.decryptFile(content.file).done((url) => {
|
decryptFile(content.file).done((url) => {
|
||||||
this.setState({
|
this.setState({
|
||||||
decryptedUrl: url,
|
decryptedUrl: url,
|
||||||
});
|
});
|
||||||
|
@ -134,14 +134,13 @@ module.exports = React.createClass({
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var content = this.props.mxEvent.getContent();
|
const content = this.props.mxEvent.getContent();
|
||||||
|
const timelineWidth = this.refs.body.offsetWidth;
|
||||||
var thumbHeight = null;
|
const maxHeight = 600; // let images take up as much width as they can so long as the height doesn't exceed 600px.
|
||||||
var timelineWidth = this.refs.body.offsetWidth;
|
|
||||||
var maxHeight = 600; // let images take up as much width as they can so long as the height doesn't exceed 600px.
|
|
||||||
// the alternative here would be 600*timelineWidth/800; to scale them down to fit inside a 4:3 bounding box
|
// the alternative here would be 600*timelineWidth/800; to scale them down to fit inside a 4:3 bounding box
|
||||||
|
|
||||||
//console.log("trying to fit image into timelineWidth of " + this.refs.body.offsetWidth + " or " + this.refs.body.clientWidth);
|
//console.log("trying to fit image into timelineWidth of " + this.refs.body.offsetWidth + " or " + this.refs.body.clientWidth);
|
||||||
|
var thumbHeight = null;
|
||||||
if (content.info) {
|
if (content.info) {
|
||||||
thumbHeight = ImageUtils.thumbHeight(content.info.w, content.info.h, timelineWidth, maxHeight);
|
thumbHeight = ImageUtils.thumbHeight(content.info.w, content.info.h, timelineWidth, maxHeight);
|
||||||
}
|
}
|
||||||
|
@ -150,8 +149,8 @@ module.exports = React.createClass({
|
||||||
},
|
},
|
||||||
|
|
||||||
render: function() {
|
render: function() {
|
||||||
var TintableSvg = sdk.getComponent("elements.TintableSvg");
|
const TintableSvg = sdk.getComponent("elements.TintableSvg");
|
||||||
var content = this.props.mxEvent.getContent();
|
const content = this.props.mxEvent.getContent();
|
||||||
|
|
||||||
if (content.file !== undefined && this.state.decryptedUrl === null) {
|
if (content.file !== undefined && this.state.decryptedUrl === null) {
|
||||||
|
|
||||||
|
@ -166,8 +165,8 @@ module.exports = React.createClass({
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
var contentUrl = this._getContentUrl();
|
const contentUrl = this._getContentUrl();
|
||||||
var thumbUrl = this._getThumbUrl();
|
const thumbUrl = this._getThumbUrl();
|
||||||
|
|
||||||
if (thumbUrl) {
|
if (thumbUrl) {
|
||||||
return (
|
return (
|
||||||
|
|
|
@ -21,7 +21,7 @@ import MFileBody from './MFileBody';
|
||||||
import MatrixClientPeg from '../../../MatrixClientPeg';
|
import MatrixClientPeg from '../../../MatrixClientPeg';
|
||||||
import Model from '../../../Modal';
|
import Model from '../../../Modal';
|
||||||
import sdk from '../../../index';
|
import sdk from '../../../index';
|
||||||
import DecryptFile from '../../../utils/DecryptFile';
|
import {decryptFile} from '../../../utils/DecryptFile';
|
||||||
|
|
||||||
module.exports = React.createClass({
|
module.exports = React.createClass({
|
||||||
displayName: 'MVideoBody',
|
displayName: 'MVideoBody',
|
||||||
|
@ -80,19 +80,19 @@ module.exports = React.createClass({
|
||||||
if (content.file !== undefined && this.state.decryptedUrl === null) {
|
if (content.file !== undefined && this.state.decryptedUrl === null) {
|
||||||
var thumbnailPromise = Promise.resolve(null);
|
var thumbnailPromise = Promise.resolve(null);
|
||||||
if (content.info.thumbnail_file) {
|
if (content.info.thumbnail_file) {
|
||||||
thumbnailPromise = DecryptFile.decryptFile(
|
thumbnailPromise = decryptFile(
|
||||||
content.info.thumbnail_file
|
content.info.thumbnail_file
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
thumbnailPromise.done((thumbnailUrl) => {
|
thumbnailPromise.then(function (thumbnailUrl) {
|
||||||
DecryptFile.decryptFile(
|
decryptFile(content.file).then(function(contentUrl) {
|
||||||
content.file
|
return {
|
||||||
).then(function(contentUrl) {
|
|
||||||
this.setState({
|
|
||||||
decryptedUrl: contentUrl,
|
decryptedUrl: contentUrl,
|
||||||
decryptedThumbnailUrl: thumbnailUrl,
|
decryptedThumbnailUrl: thumbnailUrl,
|
||||||
});
|
};
|
||||||
});
|
});
|
||||||
|
}).done((state) => {
|
||||||
|
this.setState(result);
|
||||||
}, (err) => {
|
}, (err) => {
|
||||||
console.warn("Unable to decrypt attachment: ", err)
|
console.warn("Unable to decrypt attachment: ", err)
|
||||||
// Set a placeholder image when we can't decrypt the image.
|
// Set a placeholder image when we can't decrypt the image.
|
||||||
|
|
Loading…
Reference in a new issue