From 2eaa199e6ad2742fbfea54f7d6584bd5c8ac005a Mon Sep 17 00:00:00 2001 From: Kegan Dougal Date: Mon, 8 Sep 2014 11:55:19 -0700 Subject: Added number of users in recent rooms. --- webclient/recents/recents.html | 3 +++ 1 file changed, 3 insertions(+) (limited to 'webclient/recents/recents.html') diff --git a/webclient/recents/recents.html b/webclient/recents/recents.html index 280d0632ab..b903412815 100644 --- a/webclient/recents/recents.html +++ b/webclient/recents/recents.html @@ -8,6 +8,9 @@ {{ room.room_id | mRoomName }} + + {{ room.numUsersInRoom }} users + {{ (room.lastMsg.ts) | date:'MMM d HH:mm' }} -- cgit 1.4.1 From 76fe7d4eba334cee8b5c18ac26da709106dff1a2 Mon Sep 17 00:00:00 2001 From: Kegan Dougal Date: Mon, 8 Sep 2014 12:11:36 -0700 Subject: Added num_joined_users key to /publicRooms for each room. Show this information in the webclient. --- synapse/handlers/room.py | 6 ++++++ webclient/app.css | 4 ++++ webclient/home/home.html | 5 ++++- webclient/recents/recents.html | 2 +- 4 files changed, 15 insertions(+), 2 deletions(-) (limited to 'webclient/recents/recents.html') diff --git a/synapse/handlers/room.py b/synapse/handlers/room.py index a0d0f2af16..310cb46fe7 100644 --- a/synapse/handlers/room.py +++ b/synapse/handlers/room.py @@ -593,6 +593,12 @@ class RoomListHandler(BaseHandler): @defer.inlineCallbacks def get_public_room_list(self): chunk = yield self.store.get_rooms(is_public=True) + for room in chunk: + joined_members = yield self.store.get_room_members( + room_id=room["room_id"], + membership=Membership.JOIN + ) + room["num_joined_members"] = len(joined_members) # FIXME (erikj): START is no longer a valid value defer.returnValue({"start": "START", "end": "END", "chunk": chunk}) diff --git a/webclient/app.css b/webclient/app.css index 0c6ae9b668..b438cf0405 100755 --- a/webclient/app.css +++ b/webclient/app.css @@ -273,6 +273,10 @@ a:active { color: #000; } font-weight: bold; } +.publicRoomEntry { + margin-bottom: 5px; +} + /*** Participant list ***/ #usersTableWrapper { diff --git a/webclient/home/home.html b/webclient/home/home.html index 12b3c7f14e..cf6771814c 100644 --- a/webclient/home/home.html +++ b/webclient/home/home.html @@ -25,11 +25,14 @@

Public rooms

-
+
{{ room.room_display_name }} +
+ {{ room.num_joined_members }} {{ room.num_joined_members == 1 ? 'user' : 'users' }} +

diff --git a/webclient/recents/recents.html b/webclient/recents/recents.html index b903412815..efc5c39689 100644 --- a/webclient/recents/recents.html +++ b/webclient/recents/recents.html @@ -9,7 +9,7 @@ {{ room.room_id | mRoomName }} - {{ room.numUsersInRoom }} users + {{ room.numUsersInRoom }} {{ room.numUsersInRoom == 1 ? 'user' : 'users' }} {{ (room.lastMsg.ts) | date:'MMM d HH:mm' }} -- cgit 1.4.1 From a3590dfa262d0113a354591676942e05c20b5cbf Mon Sep 17 00:00:00 2001 From: Kegan Dougal Date: Mon, 8 Sep 2014 14:01:34 -0700 Subject: Bodge to default to '1 users' when you create a room, which is better than blindly assuming a recents controller is writing to rootScope.rooms and setting numUsersInRoom there. --- webclient/recents/recents-controller.js | 5 +++++ webclient/recents/recents.html | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) (limited to 'webclient/recents/recents.html') diff --git a/webclient/recents/recents-controller.js b/webclient/recents/recents-controller.js index b4762acd1d..701c935742 100644 --- a/webclient/recents/recents-controller.js +++ b/webclient/recents/recents-controller.js @@ -82,6 +82,11 @@ angular.module('RecentsController', ['matrixService', 'matrixFilter', 'eventHand eventHandlerService.waitForInitialSyncCompletion().then( function(initialSyncData) { + // XXX FIXME TODO: + // Any assignments to the rootScope here should be done in + // event handler service and not here, because we could have + // many controllers manipulating and clobbering each other, and + // are unecessarily repeating http requests. var rooms = initialSyncData.data.rooms; for (var i=0; i - {{ room.numUsersInRoom }} {{ room.numUsersInRoom == 1 ? 'user' : 'users' }} + {{ room.numUsersInRoom || '1' }} {{ room.numUsersInRoom == 1 ? 'user' : 'users' }} {{ (room.lastMsg.ts) | date:'MMM d HH:mm' }} -- cgit 1.4.1 From 967ac65586b32543c77c68ba9d2e043d061ac549 Mon Sep 17 00:00:00 2001 From: Emmanuel ROHEE Date: Tue, 9 Sep 2014 10:46:15 +0200 Subject: BF: Made the grey background of the current room cover all the cell width --- webclient/recents/recents.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'webclient/recents/recents.html') diff --git a/webclient/recents/recents.html b/webclient/recents/recents.html index 4972e401f6..4726b61cb3 100644 --- a/webclient/recents/recents.html +++ b/webclient/recents/recents.html @@ -17,7 +17,7 @@ - +
{{ room.lastMsg.inviter | mUserDisplayName: room.room_id }} invited you -- cgit 1.4.1 From 811716592c71657a80b181b664639d19f9d1988e Mon Sep 17 00:00:00 2001 From: Emmanuel ROHEE Date: Wed, 10 Sep 2014 16:46:06 +0200 Subject: Made users count auto updating. Do show it if the info is not available (ex:user has not joined the room yet) --- webclient/recents/recents-controller.js | 38 +++++++++++++++++++++++---------- webclient/recents/recents.html | 4 +++- 2 files changed, 30 insertions(+), 12 deletions(-) (limited to 'webclient/recents/recents.html') diff --git a/webclient/recents/recents-controller.js b/webclient/recents/recents-controller.js index aedc7b7a49..5cf74cad4e 100644 --- a/webclient/recents/recents-controller.js +++ b/webclient/recents/recents-controller.js @@ -48,6 +48,9 @@ angular.module('RecentsController', ['matrixService', 'matrixFilter', 'eventHand if ($rootScope.rooms[event.room_id]) { $rootScope.rooms[event.room_id].lastMsg = event; } + + // Update room users count + $rootScope.rooms[event.room_id].numUsersInRoom = getUsersCountInRoom(event.room_id); } }); $rootScope.$on(eventHandlerService.MSG_EVENT, function(ngEvent, event, isLive) { @@ -67,6 +70,29 @@ angular.module('RecentsController', ['matrixService', 'matrixFilter', 'eventHand }); }; + /** + * Compute the room users number, ie the number of members who has joined the room. + * @param {String} room_id the room id + * @returns {undefined | Number} the room users number if available + */ + var getUsersCountInRoom = function(room_id) { + var memberCount; + + var room = $rootScope.events.rooms[room_id]; + if (room) { + memberCount = 0; + + for (var i in room.members) { + var member = room.members[i]; + + if ("join" === member.membership) { + memberCount = memberCount + 1; + } + } + } + + return memberCount; + } $scope.onInit = function() { // Init recents list only once @@ -92,17 +118,7 @@ angular.module('RecentsController', ['matrixService', 'matrixFilter', 'eventHand $rootScope.rooms[room.room_id].lastMsg = room.messages.chunk[0]; } - - var numUsersInRoom = 0; - if (room.state) { - for (var j=0; j - {{ room.numUsersInRoom || '1' }} {{ room.numUsersInRoom == 1 ? 'user' : 'users' }} + + {{ room.numUsersInRoom || '1' }} {{ room.numUsersInRoom == 1 ? 'user' : 'users' }} + {{ (room.lastMsg.ts) | date:'MMM d HH:mm' }} -- cgit 1.4.1 From 7e7eb0efc14733b576942af4590683c8b749e94e Mon Sep 17 00:00:00 2001 From: Emmanuel ROHEE Date: Thu, 11 Sep 2014 11:31:24 +0200 Subject: Show room topic change in the chat history and in the recents --- .../components/matrix/event-handler-service.js | 25 ++++++++++++++++++---- webclient/recents/recents-controller.js | 5 +++++ webclient/recents/recents.html | 4 ++++ webclient/room/room.html | 5 +++++ 4 files changed, 35 insertions(+), 4 deletions(-) (limited to 'webclient/recents/recents.html') diff --git a/webclient/components/matrix/event-handler-service.js b/webclient/components/matrix/event-handler-service.js index b19ec27a9d..002a9fbd5d 100644 --- a/webclient/components/matrix/event-handler-service.js +++ b/webclient/components/matrix/event-handler-service.js @@ -35,6 +35,7 @@ angular.module('eventHandlerService', []) var POWERLEVEL_EVENT = "POWERLEVEL_EVENT"; var CALL_EVENT = "CALL_EVENT"; var NAME_EVENT = "NAME_EVENT"; + var TOPIC_EVENT = "TOPIC_EVENT"; var initialSyncDeferred = $q.defer(); @@ -170,24 +171,39 @@ angular.module('eventHandlerService', []) }; // TODO: Can this just be a generic "I am a room state event, can haz store?" - var handleRoomTopic = function(event, isLiveEvent) { + var handleRoomTopic = function(event, isLiveEvent, isStateEvent) { console.log("handleRoomTopic live="+isLiveEvent); initRoom(event.room_id); + // Add topic changes as if they were a room message + if (!isStateEvent) { + if (isLiveEvent) { + $rootScope.events.rooms[event.room_id].messages.push(event); + } + else { + $rootScope.events.rooms[event.room_id].messages.unshift(event); + } + } + // live events always update, but non-live events only update if the // ts is later. + var latestData = true; if (!isLiveEvent) { var eventTs = event.ts; var storedEvent = $rootScope.events.rooms[event.room_id][event.type]; if (storedEvent) { if (storedEvent.ts > eventTs) { // ignore it, we have a newer one already. - return; + latestData = false; } } } - $rootScope.events.rooms[event.room_id][event.type] = event; + if (latestData) { + $rootScope.events.rooms[event.room_id][event.type] = event; + } + + $rootScope.$broadcast(TOPIC_EVENT, event, isLiveEvent); }; var handleCallEvent = function(event, isLiveEvent) { @@ -229,6 +245,7 @@ angular.module('eventHandlerService', []) POWERLEVEL_EVENT: POWERLEVEL_EVENT, CALL_EVENT: CALL_EVENT, NAME_EVENT: NAME_EVENT, + TOPIC_EVENT: TOPIC_EVENT, handleEvent: function(event, isLiveEvent, isStateEvent) { // Avoid duplicated events @@ -279,7 +296,7 @@ angular.module('eventHandlerService', []) handleRoomName(event, isLiveEvent); break; case 'm.room.topic': - handleRoomTopic(event, isLiveEvent); + handleRoomTopic(event, isLiveEvent, isStateEvent); break; default: console.log("Unable to handle event type " + event.type); diff --git a/webclient/recents/recents-controller.js b/webclient/recents/recents-controller.js index 5cf74cad4e..8ce0969164 100644 --- a/webclient/recents/recents-controller.js +++ b/webclient/recents/recents-controller.js @@ -68,6 +68,11 @@ angular.module('RecentsController', ['matrixService', 'matrixFilter', 'eventHand $rootScope.rooms[event.room_id] = event; } }); + $rootScope.$on(eventHandlerService.TOPIC_EVENT, function(ngEvent, event, isLive) { + if (isLive) { + $rootScope.rooms[event.room_id].lastMsg = event; + } + }); }; /** diff --git a/webclient/recents/recents.html b/webclient/recents/recents.html index d6bea52cbe..6976bab879 100644 --- a/webclient/recents/recents.html +++ b/webclient/recents/recents.html @@ -76,6 +76,10 @@
+
+ {{ room.lastMsg.user_id | mUserDisplayName: room.room_id }} changed the topic to: {{ room.lastMsg.content.topic }} +
+
Call diff --git a/webclient/room/room.html b/webclient/room/room.html index 054b876f81..dba6586e00 100644 --- a/webclient/room/room.html +++ b/webclient/room/room.html @@ -113,6 +113,11 @@ ng-click="$parent.fullScreenImageURL = msg.content.url"/>
+ + + {{ members[msg.user_id].displayname || msg.user_id }} changed the topic to: {{ msg.content.topic }} + + -- cgit 1.4.1 From 6ea20f3503d56457d6b027e2404a701377a69e76 Mon Sep 17 00:00:00 2001 From: Emmanuel ROHEE Date: Fri, 12 Sep 2014 10:12:56 +0200 Subject: Show room name updates in room history and recents. Update it with the latest value --- .../components/matrix/event-handler-service.js | 74 +++++++++++----------- webclient/components/matrix/matrix-filter.js | 6 +- webclient/recents/recents.html | 4 ++ webclient/room/room.html | 4 ++ 4 files changed, 50 insertions(+), 38 deletions(-) (limited to 'webclient/recents/recents.html') diff --git a/webclient/components/matrix/event-handler-service.js b/webclient/components/matrix/event-handler-service.js index 5aabc899b8..1f32289bdf 100644 --- a/webclient/components/matrix/event-handler-service.js +++ b/webclient/components/matrix/event-handler-service.js @@ -60,7 +60,7 @@ angular.module('eventHandlerService', []) // Pagination information $rootScope.events.rooms[room_id].pagination = { earliest_token: "END" // how far back we've paginated - } + }; } }; @@ -70,6 +70,36 @@ angular.module('eventHandlerService', []) } }; + // Generic method to handle events data + var handleRoomDateEvent = function(event, isLiveEvent, addToRoomMessages) { + // Add topic changes as if they were a room message + if (addToRoomMessages) { + if (isLiveEvent) { + $rootScope.events.rooms[event.room_id].messages.push(event); + } + else { + $rootScope.events.rooms[event.room_id].messages.unshift(event); + } + } + + // live events always update, but non-live events only update if the + // ts is later. + var latestData = true; + if (!isLiveEvent) { + var eventTs = event.ts; + var storedEvent = $rootScope.events.rooms[event.room_id][event.type]; + if (storedEvent) { + if (storedEvent.ts > eventTs) { + // ignore it, we have a newer one already. + latestData = false; + } + } + } + if (latestData) { + $rootScope.events.rooms[event.room_id][event.type] = event; + } + }; + var handleRoomCreate = function(event, isLiveEvent) { // For now, we do not use the event data. Simply signal it to the app controllers $rootScope.$broadcast(ROOM_CREATE_EVENT, event, isLiveEvent); @@ -153,44 +183,16 @@ angular.module('eventHandlerService', []) } }; - var handleRoomName = function(event, isLiveEvent) { - console.log("handleRoomName " + isLiveEvent); - - $rootScope.events.rooms[event.room_id][event.type] = event; + var handleRoomName = function(event, isLiveEvent, isStateEvent) { + console.log("handleRoomName room_id: " + event.room_id + " - isLiveEvent: " + isLiveEvent + " - name: " + event.content.name); + handleRoomDateEvent(event, isLiveEvent, !isStateEvent); $rootScope.$broadcast(NAME_EVENT, event, isLiveEvent); }; - // TODO: Can this just be a generic "I am a room state event, can haz store?" - var handleRoomTopic = function(event, isLiveEvent, isStateEvent) { - console.log("handleRoomTopic live="+isLiveEvent); - - // Add topic changes as if they were a room message - if (!isStateEvent) { - if (isLiveEvent) { - $rootScope.events.rooms[event.room_id].messages.push(event); - } - else { - $rootScope.events.rooms[event.room_id].messages.unshift(event); - } - } - - // live events always update, but non-live events only update if the - // ts is later. - var latestData = true; - if (!isLiveEvent) { - var eventTs = event.ts; - var storedEvent = $rootScope.events.rooms[event.room_id][event.type]; - if (storedEvent) { - if (storedEvent.ts > eventTs) { - // ignore it, we have a newer one already. - latestData = false; - } - } - } - if (latestData) { - $rootScope.events.rooms[event.room_id][event.type] = event; - } + var handleRoomTopic = function(event, isLiveEvent, isStateEvent) { + console.log("handleRoomTopic room_id: " + event.room_id + " - isLiveEvent: " + isLiveEvent + " - topic: " + event.content.topic); + handleRoomDateEvent(event, isLiveEvent, !isStateEvent); $rootScope.$broadcast(TOPIC_EVENT, event, isLiveEvent); }; @@ -286,7 +288,7 @@ angular.module('eventHandlerService', []) handlePowerLevels(event, isLiveEvent); break; case 'm.room.name': - handleRoomName(event, isLiveEvent); + handleRoomName(event, isLiveEvent, isStateEvent); break; case 'm.room.topic': handleRoomTopic(event, isLiveEvent, isStateEvent); diff --git a/webclient/components/matrix/matrix-filter.js b/webclient/components/matrix/matrix-filter.js index 260e0827df..015a88bcad 100644 --- a/webclient/components/matrix/matrix-filter.js +++ b/webclient/components/matrix/matrix-filter.js @@ -31,15 +31,17 @@ angular.module('matrixFilter', []) } if (undefined === roomName) { - // Else, build the name from its users + var room = $rootScope.events.rooms[room_id]; if (room) { + // Get name from room state date var room_name_event = room["m.room.name"]; - if (room_name_event) { roomName = room_name_event.content.name; } else if (room.members) { + // Else, build the name from its users + // FIXME: Is it still required? // Limit the room renaming to 1:1 room if (2 === Object.keys(room.members).length) { for (var i in room.members) { diff --git a/webclient/recents/recents.html b/webclient/recents/recents.html index 6976bab879..3fb2b43ee3 100644 --- a/webclient/recents/recents.html +++ b/webclient/recents/recents.html @@ -80,6 +80,10 @@ {{ room.lastMsg.user_id | mUserDisplayName: room.room_id }} changed the topic to: {{ room.lastMsg.content.topic }} +
+ {{ room.lastMsg.user_id | mUserDisplayName: room.room_id }} changed the room name to: {{ room.lastMsg.content.name }} +
+
Call diff --git a/webclient/room/room.html b/webclient/room/room.html index 25a8e65b97..e8d8c3f46a 100644 --- a/webclient/room/room.html +++ b/webclient/room/room.html @@ -118,6 +118,10 @@ {{ members[msg.user_id].displayname || msg.user_id }} changed the topic to: {{ msg.content.topic }} + + {{ members[msg.user_id].displayname || msg.user_id }} changed the room name to: {{ msg.content.name }} + +
-- cgit 1.4.1 From 6c81752e46f7e97363b325120961d9496634997d Mon Sep 17 00:00:00 2001 From: Emmanuel ROHEE Date: Fri, 12 Sep 2014 17:01:49 +0200 Subject: Fixed displayname resolution of emote sender --- webclient/recents/recents.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'webclient/recents/recents.html') diff --git a/webclient/recents/recents.html b/webclient/recents/recents.html index 3fb2b43ee3..3d736b6694 100644 --- a/webclient/recents/recents.html +++ b/webclient/recents/recents.html @@ -66,7 +66,7 @@
- +
-- cgit 1.4.1