diff options
author | Emmanuel ROHEE <erohee@amdocs.com> | 2014-09-12 10:12:56 +0200 |
---|---|---|
committer | Emmanuel ROHEE <erohee@amdocs.com> | 2014-09-12 10:12:56 +0200 |
commit | 6ea20f3503d56457d6b027e2404a701377a69e76 (patch) | |
tree | 96965f7d69b50be94530431a6445fb02c98a89a8 | |
parent | BF: temp workaround while /initialSync on a particular room is not available (diff) | |
download | synapse-6ea20f3503d56457d6b027e2404a701377a69e76.tar.xz |
Show room name updates in room history and recents.
Update it with the latest value
Diffstat (limited to '')
-rw-r--r-- | webclient/components/matrix/event-handler-service.js | 74 | ||||
-rw-r--r-- | webclient/components/matrix/matrix-filter.js | 6 | ||||
-rw-r--r-- | webclient/recents/recents.html | 4 | ||||
-rw-r--r-- | webclient/room/room.html | 4 |
4 files changed, 50 insertions, 38 deletions
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 }} </div> + <div ng-switch-when="m.room.name"> + {{ room.lastMsg.user_id | mUserDisplayName: room.room_id }} changed the room name to: {{ room.lastMsg.content.name }} + </div> + <div ng-switch-default> <div ng-if="room.lastMsg.type.indexOf('m.call.') === 0"> 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 }} </span> + <span ng-if="'m.room.name' === msg.type"> + {{ members[msg.user_id].displayname || msg.user_id }} changed the room name to: {{ msg.content.name }} + </span> + </div> </td> <td class="rightBlock"> |