summary refs log tree commit diff
path: root/webclient/rooms
diff options
context:
space:
mode:
authorErik Johnston <erik@matrix.org>2014-08-15 17:50:27 +0100
committerErik Johnston <erik@matrix.org>2014-08-15 17:50:27 +0100
commit7f5c7ddea9db879e500a48b47ad4f782d2d8416b (patch)
tree3332c614902b5641451da530ac9d2a3bed538a15 /webclient/rooms
parentFix some of the tests to reflect changes in the storage layer. (diff)
parentGet presence for members when you enter a room (it was coming down but wasn't... (diff)
downloadsynapse-7f5c7ddea9db879e500a48b47ad4f782d2d8416b.tar.xz
Merge branch 'master' of github.com:matrix-org/synapse into sql_refactor
Diffstat (limited to 'webclient/rooms')
-rw-r--r--webclient/rooms/rooms-controller.js25
-rw-r--r--webclient/rooms/rooms.html6
2 files changed, 22 insertions, 9 deletions
diff --git a/webclient/rooms/rooms-controller.js b/webclient/rooms/rooms-controller.js
index 2ce14e1d49..da79c23d55 100644
--- a/webclient/rooms/rooms-controller.js
+++ b/webclient/rooms/rooms-controller.js
@@ -16,11 +16,11 @@ limitations under the License.
 
 'use strict';
 
-angular.module('RoomsController', ['matrixService', 'mFileInput', 'mFileUpload'])
-.controller('RoomsController', ['$scope', '$location', 'matrixService', 'mFileUpload',
-                               function($scope, $location, matrixService, mFileUpload) {
+angular.module('RoomsController', ['matrixService', 'mFileInput', 'mFileUpload', 'eventHandlerService'])
+.controller('RoomsController', ['$scope', '$location', 'matrixService', 'mFileUpload', 'eventHandlerService',
+                               function($scope, $location, matrixService, mFileUpload, eventHandlerService) {
                                    
-    $scope.rooms = [];
+    $scope.rooms = {};
     $scope.public_rooms = [];
     $scope.newRoomId = "";
     $scope.feedback = "";
@@ -52,6 +52,18 @@ angular.module('RoomsController', ['matrixService', 'mFileInput', 'mFileUpload']
         linkedEmailList: matrixService.config().emailList // linked email list
     };
     
+    $scope.$on(eventHandlerService.MEMBER_EVENT, function(ngEvent, event, isLive) {
+        var config = matrixService.config();
+        if (event.target_user_id === config.user_id && event.content.membership === "invite") {
+            console.log("Invited to room " + event.room_id);
+            // FIXME push membership to top level key to match /im/sync
+            event.membership = event.content.membership;
+            // FIXME bodge a nicer name than the room ID for this invite.
+            event.room_alias = event.user_id + "'s room";
+            $scope.rooms[event.room_id] = event;
+        }
+    });
+    
     var assignRoomAliases = function(data) {
         for (var i=0; i<data.length; i++) {
             var alias = matrixService.getRoomIdToAliasMapping(data[i].room_id);
@@ -73,12 +85,13 @@ angular.module('RoomsController', ['matrixService', 'mFileInput', 'mFileUpload']
 
     $scope.refresh = function() {
         // List all rooms joined or been invited to
-        $scope.rooms = matrixService.rooms();
         matrixService.rooms().then(
             function(response) {
                 var data = assignRoomAliases(response.data);
                 $scope.feedback = "Success";
-                $scope.rooms = data;
+                for (var i=0; i<data.length; i++) {
+                    $scope.rooms[data[i].room_id] = data[i];
+                }
             },
             function(error) {
                 $scope.feedback = "Failure: " + error.data;
diff --git a/webclient/rooms/rooms.html b/webclient/rooms/rooms.html
index 5974bd940c..c3ee85f8a0 100644
--- a/webclient/rooms/rooms.html
+++ b/webclient/rooms/rooms.html
@@ -61,9 +61,9 @@
     
     <h3>My rooms</h3>
     
-    <div class="rooms" ng-repeat="room in rooms">
+    <div class="rooms" ng-repeat="(rm_id, room) in rooms">
         <div>
-            <a href="#/room/{{ room.room_id }}" >{{ room.room_alias }}</a>
+            <a href="#/room/{{ rm_id }}" >{{ room.room_alias }}</a> {{room.membership === 'invite' ? ' (invited)' : ''}}
         </div>
     </div>
     <br/>
@@ -86,7 +86,7 @@
     </div>
     <div>
         <form>
-            <input size="40" ng-model="joinAlias.room_alias" ng-enter="joinAlias(joinAlias.room_alias)" placeholder="(e.g. #foo_channe:example.org)"/>
+            <input size="40" ng-model="joinAlias.room_alias" ng-enter="joinAlias(joinAlias.room_alias)" placeholder="(e.g. #foo_channel:example.org)"/>
             <button ng-disabled="!joinAlias.room_alias" ng-click="joinAlias(joinAlias.room_alias)">Join room</button>    
         </form>
     </div>