From e632fcd933b7259853ba0522e052e73fd4f4e71a Mon Sep 17 00:00:00 2001 From: Kegan Dougal Date: Wed, 12 Nov 2014 14:31:30 +0000 Subject: 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/room/room-controller.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'syweb/webclient/room') diff --git a/syweb/webclient/room/room-controller.js b/syweb/webclient/room/room-controller.js index 6928754c5d..cf6ec08932 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(); -- cgit 1.4.1 From 96cd467cfa129acaf8814e574c7cc2a9a94459c5 Mon Sep 17 00:00:00 2001 From: Kegan Dougal Date: Wed, 12 Nov 2014 14:55:57 +0000 Subject: Add recents-service to store shared state between recents-controllers. Remove the selectedRoomId from rootScope and instead store it in recents-service. Add a broadcast to notify listeners (recents-controller) to updates of this. --- syweb/webclient/app.js | 1 + .../webclient/components/matrix/recents-service.js | 51 ++++++++++++++++++++++ syweb/webclient/index.html | 1 + syweb/webclient/recents/recents-controller.js | 15 ++++--- syweb/webclient/room/room-controller.js | 6 +-- 5 files changed, 65 insertions(+), 9 deletions(-) create mode 100644 syweb/webclient/components/matrix/recents-service.js (limited to 'syweb/webclient/room') diff --git a/syweb/webclient/app.js b/syweb/webclient/app.js index 17b2bb6e8f..35190a71f4 100644 --- a/syweb/webclient/app.js +++ b/syweb/webclient/app.js @@ -31,6 +31,7 @@ var matrixWebClient = angular.module('matrixWebClient', [ 'eventStreamService', 'eventHandlerService', 'notificationService', + 'recentsService', 'modelService', 'infinite-scroll', 'ui.bootstrap', diff --git a/syweb/webclient/components/matrix/recents-service.js b/syweb/webclient/components/matrix/recents-service.js new file mode 100644 index 0000000000..64d1ab93b4 --- /dev/null +++ b/syweb/webclient/components/matrix/recents-service.js @@ -0,0 +1,51 @@ +/* +Copyright 2014 OpenMarket Ltd + +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'; + +/* +This service manages shared state between *instances* of recent lists. The +recents controller will hook into this central service to get things like: +- which rooms should be highlighted +- which rooms have been binged +- which room is currently selected +- etc. +This is preferable to polluting the $rootScope with recents specific info, and +makes the dependency on this shared state *explicit*. +*/ +angular.module('recentsService', []) +.factory('recentsService', ['$rootScope', function($rootScope) { + // notify listeners when variables in the service are updated. We need to do + // this since we do not tie them to any scope. + var BROADCAST_SELECTED_ROOM_ID = "recentsService:BROADCAST_SELECTED_ROOM_ID"; + var selectedRoomId = undefined; + + + return { + BROADCAST_SELECTED_ROOM_ID: BROADCAST_SELECTED_ROOM_ID, + + getSelectedRoomId: function() { + return selectedRoomId; + }, + + setSelectedRoomId: function(room_id) { + selectedRoomId = room_id; + $rootScope.$broadcast(BROADCAST_SELECTED_ROOM_ID, room_id); + } + + }; + +}]); diff --git a/syweb/webclient/index.html b/syweb/webclient/index.html index f6487f381d..4bca320e77 100644 --- a/syweb/webclient/index.html +++ b/syweb/webclient/index.html @@ -44,6 +44,7 @@ + diff --git a/syweb/webclient/recents/recents-controller.js b/syweb/webclient/recents/recents-controller.js index 062d106018..78aeca128d 100644 --- a/syweb/webclient/recents/recents-controller.js +++ b/syweb/webclient/recents/recents-controller.js @@ -17,8 +17,8 @@ '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; @@ -31,8 +31,11 @@ angular.module('RecentsController', ['matrixService', 'matrixFilter']) // room_id: }; } - - // $rootScope.recentsSelectedRoomID is used in the html, and is set by room-controller. + + $scope.recentsSelectedRoomID = recentsService.getSelectedRoomId(); + $scope.$on(recentsService.BROADCAST_SELECTED_ROOM_ID, function(ngEvent, room_id) { + $scope.recentsSelectedRoomID = room_id; + }); $scope.selectRoom = function(room) { @@ -43,12 +46,12 @@ angular.module('RecentsController', ['matrixService', 'matrixFilter']) }; $scope.$on(eventHandlerService.MSG_EVENT, function(ngEvent, event, isLive) { - if (isLive && event.room_id !== $rootScope.recentsSelectedRoomID) { + if (isLive && event.room_id !== $scope.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)); + console.log("sel="+$scope.recentsSelectedRoomID+" unread:"+JSON.stringify($rootScope.unreadMessages, undefined, 2)); } }); diff --git a/syweb/webclient/room/room-controller.js b/syweb/webclient/room/room-controller.js index cf6ec08932..ab1772e9e3 100644 --- a/syweb/webclient/room/room-controller.js +++ b/syweb/webclient/room/room-controller.js @@ -15,8 +15,8 @@ limitations under the License. */ angular.module('RoomController', ['ngSanitize', 'matrixFilter', 'mFileInput', 'angular-peity']) -.controller('RoomController', ['$modal', '$filter', '$scope', '$timeout', '$routeParams', '$location', '$rootScope', 'matrixService', 'mPresence', 'eventHandlerService', 'mFileUpload', 'matrixPhoneService', 'MatrixCall', 'notificationService', 'modelService', - function($modal, $filter, $scope, $timeout, $routeParams, $location, $rootScope, matrixService, mPresence, eventHandlerService, mFileUpload, matrixPhoneService, MatrixCall, notificationService, modelService) { +.controller('RoomController', ['$modal', '$filter', '$scope', '$timeout', '$routeParams', '$location', '$rootScope', 'matrixService', 'mPresence', 'eventHandlerService', 'mFileUpload', 'matrixPhoneService', 'MatrixCall', 'notificationService', 'modelService', 'recentsService', + function($modal, $filter, $scope, $timeout, $routeParams, $location, $rootScope, matrixService, mPresence, eventHandlerService, mFileUpload, matrixPhoneService, MatrixCall, notificationService, modelService, recentsService) { 'use strict'; var MESSAGES_PER_PAGINATION = 30; var THUMBNAIL_SIZE = 320; @@ -804,7 +804,7 @@ angular.module('RoomController', ['ngSanitize', 'matrixFilter', 'mFileInput', 'a console.log("onInit3"); // Make recents highlight the current room - $rootScope.recentsSelectedRoomID = $scope.room_id; + recentsService.setSelectedRoomId($scope.room_id); // Init the history for this room history.init(); -- cgit 1.4.1 From f4a3b194da7e599863534fc8444a4f6fe9b6ee90 Mon Sep 17 00:00:00 2001 From: Kegan Dougal Date: Wed, 12 Nov 2014 17:06:03 +0000 Subject: Fix ability to invite users. Remove unused variables. --- syweb/webclient/room/room-controller.js | 42 +++++++++++++-------------------- syweb/webclient/room/room.html | 2 +- 2 files changed, 17 insertions(+), 27 deletions(-) (limited to 'syweb/webclient/room') diff --git a/syweb/webclient/room/room-controller.js b/syweb/webclient/room/room-controller.js index ab1772e9e3..fa542129b7 100644 --- a/syweb/webclient/room/room-controller.js +++ b/syweb/webclient/room/room-controller.js @@ -22,14 +22,7 @@ angular.module('RoomController', ['ngSanitize', 'matrixFilter', 'mFileInput', 'a var THUMBNAIL_SIZE = 320; // .html needs this - $scope.containsBingWord = function(content) { - return notificationService.containsBingWord( - matrixService.config().user_id, - matrixService.config().display_name, - matrixService.config().bingWords, - content - ); - }; + $scope.containsBingWord = eventHandlerService.eventContainsBingWord; // Room ids. Computed and resolved in onInit $scope.room_id = undefined; @@ -46,12 +39,8 @@ angular.module('RoomController', ['ngSanitize', 'matrixFilter', 'mFileInput', 'a messages_visibility: "hidden", // In order to avoid flickering when scrolling down the message table at the page opening, delay the message table display }; $scope.members = {}; - $scope.autoCompleting = false; - $scope.autoCompleteIndex = 0; - $scope.autoCompleteOriginal = ""; $scope.imageURLToSend = ""; - $scope.userIDToInvite = ""; // vars and functions for updating the name @@ -162,7 +151,6 @@ angular.module('RoomController', ['ngSanitize', 'matrixFilter', 'mFileInput', 'a $scope.$on(eventHandlerService.MSG_EVENT, function(ngEvent, event, isLive) { if (isLive && event.room_id === $scope.room_id) { - scrollToBottom(); } }); @@ -841,19 +829,6 @@ angular.module('RoomController', ['ngSanitize', 'matrixFilter', 'mFileInput', 'a } ); }; - - $scope.inviteUser = function() { - - matrixService.invite($scope.room_id, $scope.userIDToInvite).then( - function() { - console.log("Invited."); - $scope.feedback = "Invite successfully sent to " + $scope.userIDToInvite; - $scope.userIDToInvite = ""; - }, - function(reason) { - $scope.feedback = "Failure: " + reason.data.error; - }); - }; $scope.leaveRoom = function() { @@ -1091,6 +1066,21 @@ angular.module('RoomController', ['ngSanitize', 'matrixFilter', 'mFileInput', 'a }) .controller('RoomInfoController', function($scope, $modalInstance, $filter, matrixService) { console.log("Displaying room info."); + + $scope.userIDToInvite = ""; + + $scope.inviteUser = function() { + + matrixService.invite($scope.room_id, $scope.userIDToInvite).then( + function() { + console.log("Invited."); + $scope.feedback = "Invite successfully sent to " + $scope.userIDToInvite; + $scope.userIDToInvite = ""; + }, + function(reason) { + $scope.feedback = "Failure: " + reason.data.error; + }); + }; $scope.submit = function(event) { if (event.content) { diff --git a/syweb/webclient/room/room.html b/syweb/webclient/room/room.html index 1f1cd9baef..b97b839b41 100644 --- a/syweb/webclient/room/room.html +++ b/syweb/webclient/room/room.html @@ -203,7 +203,7 @@ -- cgit 1.4.1 From 2b64c573c3ad9fcfe3d884047804c5b5f1e19967 Mon Sep 17 00:00:00 2001 From: David Baker Date: Wed, 12 Nov 2014 17:27:41 +0000 Subject: Oops, change videoElement / selector in audio call too. --- syweb/webclient/room/room-controller.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'syweb/webclient/room') diff --git a/syweb/webclient/room/room-controller.js b/syweb/webclient/room/room-controller.js index fa542129b7..6670201707 100644 --- a/syweb/webclient/room/room-controller.js +++ b/syweb/webclient/room/room-controller.js @@ -898,7 +898,7 @@ angular.module('RoomController', ['ngSanitize', 'matrixFilter', 'mFileInput', 'a call.onError = $rootScope.onCallError; call.onHangup = $rootScope.onCallHangup; // remote video element is used for playing audio in voice calls - call.remoteVideoElement = angular.element('#remoteVideo')[0]; + call.remoteVideoSelector = angular.element('#remoteVideo')[0]; call.placeVoiceCall(); $rootScope.currentCall = call; }; -- cgit 1.4.1