From 308c9273fadefd072f157620225515eb7395633d Mon Sep 17 00:00:00 2001 From: Emmanuel ROHEE Date: Wed, 27 Aug 2014 15:09:16 +0200 Subject: Moved recents things into a separate (and reusable) controler --- webclient/recents/recents-controller.js | 66 +++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 webclient/recents/recents-controller.js (limited to 'webclient/recents/recents-controller.js') diff --git a/webclient/recents/recents-controller.js b/webclient/recents/recents-controller.js new file mode 100644 index 0000000000..a9805fc38a --- /dev/null +++ b/webclient/recents/recents-controller.js @@ -0,0 +1,66 @@ +/* + Copyright 2014 matrix.org + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + */ + +'use strict'; + +angular.module('RecentsController', ['matrixService', 'eventHandlerService']) +.controller('RecentsController', ['$scope', 'matrixService', 'eventHandlerService', 'eventStreamService', + function($scope, matrixService, eventHandlerService, eventStreamService) { + $scope.rooms = {}; + + $scope.$on(eventHandlerService.MEMBER_EVENT, function(ngEvent, event, isLive) { + var config = matrixService.config(); + if (event.state_key === 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_display_name = event.user_id + "'s room"; + $scope.rooms[event.room_id] = event; + } + }); + + var refresh = function() { + // List all rooms joined or been invited to + matrixService.rooms(1, false).then( + function(response) { + var data = matrixService.assignRoomAliases(response.data.rooms); + for (var i=0; i Date: Wed, 27 Aug 2014 17:20:41 +0200 Subject: Highlight the current room in the recents list --- webclient/app.css | 4 ++++ webclient/recents/recents-controller.js | 6 +++++- webclient/recents/recents.html | 5 ++++- webclient/room/room-controller.js | 3 +++ 4 files changed, 16 insertions(+), 2 deletions(-) (limited to 'webclient/recents/recents-controller.js') diff --git a/webclient/app.css b/webclient/app.css index e2526dcbaa..8abdd1cb44 100644 --- a/webclient/app.css +++ b/webclient/app.css @@ -368,6 +368,10 @@ h1 { background-color: #f8f8ff; } +.recentsRoomSelected { + background-color: #eee; +} + .recentsRoomName { font-size: 16px; padding-top: 7px; diff --git a/webclient/recents/recents-controller.js b/webclient/recents/recents-controller.js index a9805fc38a..8f8b08d5bd 100644 --- a/webclient/recents/recents-controller.js +++ b/webclient/recents/recents-controller.js @@ -20,7 +20,11 @@ angular.module('RecentsController', ['matrixService', 'eventHandlerService']) .controller('RecentsController', ['$scope', 'matrixService', 'eventHandlerService', 'eventStreamService', function($scope, matrixService, eventHandlerService, eventStreamService) { $scope.rooms = {}; - + + // $scope of the parent where the recents component is included can override this value + // in order to highlight a specific room in the list + $scope.recentsSelectedRoomID; + $scope.$on(eventHandlerService.MEMBER_EVENT, function(ngEvent, event, isLive) { var config = matrixService.config(); if (event.state_key === config.user_id && event.content.membership === "invite") { diff --git a/webclient/recents/recents.html b/webclient/recents/recents.html index 6d2864ac97..6fda6c5c6b 100644 --- a/webclient/recents/recents.html +++ b/webclient/recents/recents.html @@ -1,6 +1,9 @@
- +
{{ room.room_display_name }} diff --git a/webclient/room/room-controller.js b/webclient/room/room-controller.js index f49deaa489..641ccddce7 100644 --- a/webclient/room/room-controller.js +++ b/webclient/room/room-controller.js @@ -327,6 +327,9 @@ angular.module('RoomController', ['ngSanitize', 'mUtilities']) var onInit2 = function() { eventHandlerService.reInitRoom($scope.room_id); + // Make recents highlight the current room + $scope.recentsSelectedRoomID = $scope.room_id; + // Join the room matrixService.join($scope.room_id).then( function() { -- cgit 1.5.1