diff options
Diffstat (limited to 'webclient/home/home-controller.js')
-rw-r--r-- | webclient/home/home-controller.js | 42 |
1 files changed, 37 insertions, 5 deletions
diff --git a/webclient/home/home-controller.js b/webclient/home/home-controller.js index 547a5c5603..f4ce3053ea 100644 --- a/webclient/home/home-controller.js +++ b/webclient/home/home-controller.js @@ -17,8 +17,8 @@ limitations under the License. 'use strict'; angular.module('HomeController', ['matrixService', 'eventHandlerService', 'RecentsController']) -.controller('HomeController', ['$scope', '$location', 'matrixService', - function($scope, $location, matrixService) { +.controller('HomeController', ['$scope', '$location', 'matrixService', 'eventHandlerService', + function($scope, $location, matrixService, eventHandlerService) { $scope.config = matrixService.config(); $scope.public_rooms = []; @@ -37,6 +37,11 @@ angular.module('HomeController', ['matrixService', 'eventHandlerService', 'Recen $scope.joinAlias = { room_alias: "" }; + + $scope.profile = { + displayName: "", + avatarUrl: "" + }; var refresh = function() { @@ -53,21 +58,20 @@ angular.module('HomeController', ['matrixService', 'eventHandlerService', 'Recen ); }; - $scope.createNewRoom = function(room_id, isPrivate) { + $scope.createNewRoom = function(room_alias, isPrivate) { var visibility = "public"; if (isPrivate) { visibility = "private"; } - matrixService.create(room_id, visibility).then( + matrixService.create(room_alias, visibility).then( function(response) { // This room has been created. Refresh the rooms list console.log("Created room " + response.data.room_alias + " with id: "+ response.data.room_id); matrixService.createRoomIdToAliasMapping( response.data.room_id, response.data.room_alias); - refresh(); }, function(error) { $scope.feedback = "Failure: " + error.data; @@ -108,6 +112,34 @@ angular.module('HomeController', ['matrixService', 'eventHandlerService', 'Recen }; $scope.onInit = function() { + // Load profile data + // Display name + matrixService.getDisplayName($scope.config.user_id).then( + function(response) { + $scope.profile.displayName = response.data.displayname; + }, + function(error) { + $scope.feedback = "Can't load display name"; + } + ); + // Avatar + matrixService.getProfilePictureUrl($scope.config.user_id).then( + function(response) { + $scope.profile.avatarUrl = response.data.avatar_url; + }, + function(error) { + $scope.feedback = "Can't load avatar URL"; + } + ); + + // Listen to room creation event in order to update the public rooms list + $scope.$on(eventHandlerService.ROOM_CREATE_EVENT, function(ngEvent, event, isLive) { + if (isLive) { + // As we do not know if this room is public, do a full list refresh + refresh(); + } + }); + refresh(); }; }]); |