From 466fbe4c4e034125b9db6f859387ce1141efe425 Mon Sep 17 00:00:00 2001 From: Emmanuel ROHEE Date: Thu, 28 Aug 2014 11:14:36 +0200 Subject: Cleaned up deps --- webclient/recents/recents-controller.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'webclient/recents') diff --git a/webclient/recents/recents-controller.js b/webclient/recents/recents-controller.js index bf6a1b8874..e182a3ad23 100644 --- a/webclient/recents/recents-controller.js +++ b/webclient/recents/recents-controller.js @@ -17,8 +17,8 @@ 'use strict'; angular.module('RecentsController', ['matrixService', 'eventHandlerService']) -.controller('RecentsController', ['$scope', 'matrixService', 'eventHandlerService', 'eventStreamService', - function($scope, matrixService, eventHandlerService, eventStreamService) { +.controller('RecentsController', ['$scope', 'matrixService', 'eventHandlerService', + function($scope, matrixService, eventHandlerService) { $scope.rooms = {}; // $scope of the parent where the recents component is included can override this value -- cgit 1.4.1 From b09e531159c56a8f08c5ead81dbba40f923db822 Mon Sep 17 00:00:00 2001 From: Emmanuel ROHEE Date: Thu, 28 Aug 2014 16:38:00 +0200 Subject: Do a smart update of the recents from the events stream rather than hammering initialSync each time --- webclient/recents/recents-controller.js | 28 +++++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-) (limited to 'webclient/recents') diff --git a/webclient/recents/recents-controller.js b/webclient/recents/recents-controller.js index e182a3ad23..803ab420f9 100644 --- a/webclient/recents/recents-controller.js +++ b/webclient/recents/recents-controller.js @@ -25,13 +25,24 @@ angular.module('RecentsController', ['matrixService', 'eventHandlerService']) // in order to highlight a specific room in the list $scope.recentsSelectedRoomID; - // Refresh the list on matrix invitation and message event - $scope.$on(eventHandlerService.MEMBER_EVENT, function(ngEvent, event, isLive) { - refresh(); - }); - $scope.$on(eventHandlerService.MSG_EVENT, function(ngEvent, event, isLive) { - refresh(); - }); + var listenToEventStream = function() { + // Refresh the list on matrix invitation and message event + $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; + } + }); + $scope.$on(eventHandlerService.MSG_EVENT, function(ngEvent, event, isLive) { + $scope.rooms[event.room_id].lastMsg = event; + }); + }; + var refresh = function() { // List all rooms joined or been invited to @@ -56,6 +67,9 @@ angular.module('RecentsController', ['matrixService', 'eventHandlerService']) for (var i = 0; i < presence.length; ++i) { eventHandlerService.handleEvent(presence[i], false); } + + // From now, update recents from the stream + listenToEventStream(); }, function(error) { $scope.feedback = "Failure: " + error.data; -- cgit 1.4.1 From 246b2a3c3e039bd1eef447cf1e7b5f78bcce20a3 Mon Sep 17 00:00:00 2001 From: Emmanuel ROHEE Date: Thu, 28 Aug 2014 17:48:55 +0200 Subject: Renamed matrixService.assignRoomAliases into getRoomAliasAndDisplayName --- webclient/components/matrix/matrix-service.js | 56 ++++++++++++++------------- webclient/home/home-controller.js | 8 +++- webclient/recents/recents-controller.js | 13 ++++--- 3 files changed, 45 insertions(+), 32 deletions(-) (limited to 'webclient/recents') diff --git a/webclient/components/matrix/matrix-service.js b/webclient/components/matrix/matrix-service.js index 2feddac5d8..9fde5496ee 100644 --- a/webclient/components/matrix/matrix-service.js +++ b/webclient/components/matrix/matrix-service.js @@ -420,34 +420,38 @@ angular.module('matrixService', []) /****** Room aliases management ******/ /** - * Enhance data returned by rooms() and publicRooms() by adding room_alias - * & room_display_name which are computed from data already retrieved from the server. - * @param {Array} data the response of rooms() and publicRooms() - * @returns {Array} the same array with enriched objects + * Get the room_alias & room_display_name which are computed from data + * already retrieved from the server. + * @param {Room object} room one element of the array returned by the response + * of rooms() and publicRooms() + * @returns {Object} {room_alias: "...", room_display_name: "..."} */ - assignRoomAliases: function(data) { - for (var i=0; i Date: Fri, 29 Aug 2014 09:49:03 +0200 Subject: Display emotes in the recents list --- webclient/recents/recents.html | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'webclient/recents') diff --git a/webclient/recents/recents.html b/webclient/recents/recents.html index 6fda6c5c6b..3f025a98d8 100644 --- a/webclient/recents/recents.html +++ b/webclient/recents/recents.html @@ -39,6 +39,11 @@ {{ room.lastMsg.user_id }} sent an image +
+ + +
+
{{ room.lastMsg.content }}
-- cgit 1.4.1 From 089d1b1b78f4d98afbe1eee070da5e4ad20d6664 Mon Sep 17 00:00:00 2001 From: Emmanuel ROHEE Date: Fri, 29 Aug 2014 09:55:47 +0200 Subject: Recents update: do not care of events coming from the past (they are fired when doing pagination of room messages in the past) --- webclient/recents/recents-controller.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'webclient/recents') diff --git a/webclient/recents/recents-controller.js b/webclient/recents/recents-controller.js index 1ead08cae8..d33d41a922 100644 --- a/webclient/recents/recents-controller.js +++ b/webclient/recents/recents-controller.js @@ -29,7 +29,7 @@ angular.module('RecentsController', ['matrixService', 'eventHandlerService']) // Refresh the list on matrix invitation and message event $scope.$on(eventHandlerService.MEMBER_EVENT, function(ngEvent, event, isLive) { var config = matrixService.config(); - if (event.state_key === config.user_id && event.content.membership === "invite") { + if (isLive && 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; @@ -39,7 +39,9 @@ angular.module('RecentsController', ['matrixService', 'eventHandlerService']) } }); $scope.$on(eventHandlerService.MSG_EVENT, function(ngEvent, event, isLive) { - $scope.rooms[event.room_id].lastMsg = event; + if (isLive) { + $scope.rooms[event.room_id].lastMsg = event; + } }); }; -- cgit 1.4.1