diff options
author | Corey Hulen <corey@hulen.com> | 2015-08-25 13:17:21 -0700 |
---|---|---|
committer | Corey Hulen <corey@hulen.com> | 2015-08-25 13:17:21 -0700 |
commit | eb5af31c17f1f8ff1dabdbfeaf4d7ae24700d6ac (patch) | |
tree | 8407caf850b9246b30d7ce2ca6726e66244b7ce2 /web/react/components | |
parent | b4ee26373042d2c5ab422a4955022fb278cb8fa1 (diff) | |
parent | 64b179ab0e6a66c0f8edb72ab24ef28bbc2f9969 (diff) | |
download | chat-eb5af31c17f1f8ff1dabdbfeaf4d7ae24700d6ac.tar.gz chat-eb5af31c17f1f8ff1dabdbfeaf4d7ae24700d6ac.tar.bz2 chat-eb5af31c17f1f8ff1dabdbfeaf4d7ae24700d6ac.zip |
Merge pull request #466 from mattermost/mm-1912
Fixes mm-1912 move get file info into its own web service call
Diffstat (limited to 'web/react/components')
-rw-r--r-- | web/react/components/file_attachment.jsx | 15 | ||||
-rw-r--r-- | web/react/components/view_image.jsx | 17 |
2 files changed, 21 insertions, 11 deletions
diff --git a/web/react/components/file_attachment.jsx b/web/react/components/file_attachment.jsx index c36c908d2..ab550d500 100644 --- a/web/react/components/file_attachment.jsx +++ b/web/react/components/file_attachment.jsx @@ -2,6 +2,7 @@ // See License.txt for license information. var utils = require('../utils/utils.jsx'); +var Client = require('../utils/client.jsx'); var Constants = require('../utils/constants.jsx'); module.exports = React.createClass({ @@ -103,12 +104,16 @@ module.exports = React.createClass({ if (this.state.fileSize < 0) { var self = this; - // asynchronously request the size of the file so that we can display it next to the thumbnail - utils.getFileSize(utils.getFileUrl(filename), function(fileSize) { - if (self.canSetState) { - self.setState({fileSize: fileSize}); + Client.getFileInfo( + filename, + function(data) { + if (self.canSetState) { + self.setState({fileSize: parseInt(data["size"], 10)}); + } + }, + function(err) { } - }); + ); } else { fileSizeString = utils.fileSizeToString(this.state.fileSize); } diff --git a/web/react/components/view_image.jsx b/web/react/components/view_image.jsx index 6077c4ebc..fefd8d57d 100644 --- a/web/react/components/view_image.jsx +++ b/web/react/components/view_image.jsx @@ -229,13 +229,18 @@ module.exports = React.createClass({ if (!(filename in this.state.fileSizes)) { var self = this; - utils.getFileSize(utils.getFileUrl(filename), function fileSizeOp(fileSize) { - if (self.canSetState) { - var fileSizes = self.state.fileSizes; - fileSizes[filename] = fileSize; - self.setState(fileSizes); + Client.getFileInfo( + filename, + function(data) { + if (self.canSetState) { + var fileSizes = self.state.fileSizes; + fileSizes[filename] = parseInt(data["size"], 10); + self.setState(fileSizes); + } + }, + function(err) { } - }); + ); } } } else { |