diff options
Diffstat (limited to 'syweb/webclient/recents')
-rw-r--r-- | syweb/webclient/recents/recents-controller.js | 31 | ||||
-rw-r--r-- | syweb/webclient/recents/recents.html | 6 |
2 files changed, 28 insertions, 9 deletions
diff --git a/syweb/webclient/recents/recents-controller.js b/syweb/webclient/recents/recents-controller.js index 6f0be18f1a..41720d4cb0 100644 --- a/syweb/webclient/recents/recents-controller.js +++ b/syweb/webclient/recents/recents-controller.js @@ -17,18 +17,37 @@ 'use strict'; angular.module('RecentsController', ['matrixService', 'matrixFilter']) -.controller('RecentsController', ['$rootScope', '$scope', 'eventHandlerService', 'modelService', - function($rootScope, $scope, eventHandlerService, modelService) { +.controller('RecentsController', ['$rootScope', '$scope', 'eventHandlerService', 'modelService', 'recentsService', + function($rootScope, $scope, eventHandlerService, modelService, recentsService) { // Expose the service to the view $scope.eventHandlerService = eventHandlerService; // retrieve all rooms and expose them $scope.rooms = modelService.getRooms(); - - // $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; + + // track the selected room ID: the html will use this + $scope.recentsSelectedRoomID = recentsService.getSelectedRoomId(); + $scope.$on(recentsService.BROADCAST_SELECTED_ROOM_ID, function(ngEvent, room_id) { + $scope.recentsSelectedRoomID = room_id; + }); + + // track the list of unread messages: the html will use this + $scope.unreadMessages = recentsService.getUnreadMessages(); + $scope.$on(recentsService.BROADCAST_UNREAD_MESSAGES, function(ngEvent, room_id, unreadCount) { + $scope.unreadMessages = recentsService.getUnreadMessages(); + }); + + // track the list of unread BING messages: the html will use this + $scope.unreadBings = recentsService.getUnreadBingMessages(); + $scope.$on(recentsService.BROADCAST_UNREAD_BING_MESSAGES, function(ngEvent, room_id, event) { + $scope.unreadBings = recentsService.getUnreadBingMessages(); + }); + + $scope.selectRoom = function(room) { + recentsService.markAsRead(room.room_id); + $rootScope.goToPage('room/' + (room.room_alias ? room.room_alias : room.room_id) ); + }; }]); diff --git a/syweb/webclient/recents/recents.html b/syweb/webclient/recents/recents.html index 7297e23703..0b3a77ca11 100644 --- a/syweb/webclient/recents/recents.html +++ b/syweb/webclient/recents/recents.html @@ -1,9 +1,9 @@ <div ng-controller="RecentsController"> <table class="recentsTable"> <tbody ng-repeat="(index, room) in rooms | orderRecents" - ng-click="goToPage('room/' + (room.room_alias ? room.room_alias : room.room_id) )" - class="recentsRoom" - ng-class="{'recentsRoomSelected': (room.room_id === recentsSelectedRoomID)}"> + ng-click="selectRoom(room)" + class="recentsRoom" + ng-class="{'recentsRoomSelected': (room.room_id === recentsSelectedRoomID), 'recentsRoomBing': (unreadBings[room.room_id]), 'recentsRoomUnread': (unreadMessages[room.room_id])}"> <tr> <td ng-class="room.current_room_state.state('m.room.join_rules').content.join_rule == 'public' ? 'recentsRoomName recentsPublicRoom' : 'recentsRoomName'"> {{ room.room_id | mRoomName }} |