diff options
author | Emmanuel ROHEE <erohee@amdocs.com> | 2014-08-21 14:30:41 +0200 |
---|---|---|
committer | Emmanuel ROHEE <erohee@amdocs.com> | 2014-08-21 15:00:20 +0200 |
commit | aac52fce15a592ac0715f72864f144600e4c15a1 (patch) | |
tree | 5a8de90ce005b4bb827cb8ed2c80e267b784b9cf /webclient/room | |
parent | Made uploadContent compatible for sending Blob objects (diff) | |
download | synapse-aac52fce15a592ac0715f72864f144600e4c15a1.tar.xz |
Generate thumbnail client side and send its URL and info with the image message body
Diffstat (limited to '')
-rw-r--r-- | webclient/room/room-controller.js | 34 |
1 files changed, 12 insertions, 22 deletions
diff --git a/webclient/room/room-controller.js b/webclient/room/room-controller.js index 35abeeca06..7de50dd960 100644 --- a/webclient/room/room-controller.js +++ b/webclient/room/room-controller.js @@ -19,6 +19,7 @@ angular.module('RoomController', ['ngSanitize', 'mUtilities']) function($scope, $http, $timeout, $routeParams, $location, matrixService, eventStreamService, eventHandlerService, mFileUpload, mUtilities) { 'use strict'; var MESSAGES_PER_PAGINATION = 30; + var THUMBNAIL_SIZE = 320; // Room ids. Computed and resolved in onInit $scope.room_id = undefined; @@ -386,33 +387,22 @@ angular.module('RoomController', ['ngSanitize', 'mUtilities']) $scope.state.sending = true; - // First, get the image sise - mUtilities.getImageSize($scope.imageFileToSend).then( - function(size) { - - // Upload the image to the Internet - console.log("Uploading image..."); - mFileUpload.uploadFile($scope.imageFileToSend).then( - function(url) { - // Build the image info data - var imageInfo = { - size: $scope.imageFileToSend.size, - mimetype: $scope.imageFileToSend.type, - w: size.width, - h: size.height - }; - - // Then share the URL and the metadata - $scope.sendImage(url, imageInfo); + // Upload this image with its thumbnail to Internet + mFileUpload.uploadImageAndThumbnail($scope.imageFileToSend, THUMBNAIL_SIZE).then( + function(imageMessage) { + // imageMessage is complete message structure, send it as is + matrixService.sendMessage($scope.room_id, undefined, imageMessage).then( + function() { + console.log("Image message sent"); + $scope.state.sending = false; }, function(error) { - $scope.feedback = "Can't upload image"; + $scope.feedback = "Failed to send image message: " + error.data.error; $scope.state.sending = false; - } - ); + }); }, function(error) { - $scope.feedback = "Can't get selected image size"; + $scope.feedback = "Can't upload image"; $scope.state.sending = false; } ); |