From e632fcd933b7259853ba0522e052e73fd4f4e71a Mon Sep 17 00:00:00 2001 From: Kegan Dougal Date: Wed, 12 Nov 2014 14:31:30 +0000 Subject: [PATCH] SYWEB-57: Highlight rooms where the history has changed. This highlights rooms when something has happened and you haven't viewed it yet. It highlights entries in a slightly red background colour. --- syweb/webclient/app.css | 4 +++ syweb/webclient/recents/recents-controller.js | 28 +++++++++++++++++-- syweb/webclient/recents/recents.html | 6 ++-- syweb/webclient/room/room-controller.js | 2 +- 4 files changed, 33 insertions(+), 7 deletions(-) diff --git a/syweb/webclient/app.css b/syweb/webclient/app.css index 403d615bf..7a4ff0467 100755 --- a/syweb/webclient/app.css +++ b/syweb/webclient/app.css @@ -812,6 +812,10 @@ textarea, input { background-color: #eee; } +.recentsRoomUnread { + background-color: #fee; +} + .recentsRoomName { font-size: 16px; padding-top: 7px; diff --git a/syweb/webclient/recents/recents-controller.js b/syweb/webclient/recents/recents-controller.js index 6f0be18f1..062d10601 100644 --- a/syweb/webclient/recents/recents-controller.js +++ b/syweb/webclient/recents/recents-controller.js @@ -25,10 +25,32 @@ angular.module('RecentsController', ['matrixService', 'matrixFilter']) // retrieve all rooms and expose them $scope.rooms = modelService.getRooms(); + + if (!$rootScope.unreadMessages) { + $rootScope.unreadMessages = { + // room_id: + }; + } - // $rootScope of the parent where the recents component is included can override this value - // in order to highlight a specific room in the list - $rootScope.recentsSelectedRoomID; + // $rootScope.recentsSelectedRoomID is used in the html, and is set by room-controller. + + + $scope.selectRoom = function(room) { + if ($rootScope.unreadMessages[room.room_id]) { + $rootScope.unreadMessages[room.room_id] = 0; + } + $rootScope.goToPage('room/' + (room.room_alias ? room.room_alias : room.room_id) ); + }; + + $scope.$on(eventHandlerService.MSG_EVENT, function(ngEvent, event, isLive) { + if (isLive && event.room_id !== $rootScope.recentsSelectedRoomID) { + if (!$rootScope.unreadMessages[event.room_id]) { + $rootScope.unreadMessages[event.room_id] = 0; + } + $rootScope.unreadMessages[event.room_id] += 1; + console.log("sel="+$rootScope.recentsSelectedRoomID+" unread:"+JSON.stringify($rootScope.unreadMessages, undefined, 2)); + } + }); }]); diff --git a/syweb/webclient/recents/recents.html b/syweb/webclient/recents/recents.html index 7297e2370..386edb141 100644 --- a/syweb/webclient/recents/recents.html +++ b/syweb/webclient/recents/recents.html @@ -1,9 +1,9 @@
+ ng-click="selectRoom(room)" + class="recentsRoom" + ng-class="{'recentsRoomSelected': (room.room_id === recentsSelectedRoomID), 'recentsRoomUnread': (unreadMessages[room.room_id])}">
{{ room.room_id | mRoomName }} diff --git a/syweb/webclient/room/room-controller.js b/syweb/webclient/room/room-controller.js index 6928754c5..cf6ec0893 100644 --- a/syweb/webclient/room/room-controller.js +++ b/syweb/webclient/room/room-controller.js @@ -804,7 +804,7 @@ angular.module('RoomController', ['ngSanitize', 'matrixFilter', 'mFileInput', 'a console.log("onInit3"); // Make recents highlight the current room - $scope.recentsSelectedRoomID = $scope.room_id; + $rootScope.recentsSelectedRoomID = $scope.room_id; // Init the history for this room history.init();