From 308c9273fadefd072f157620225515eb7395633d Mon Sep 17 00:00:00 2001 From: Emmanuel ROHEE Date: Wed, 27 Aug 2014 15:09:16 +0200 Subject: Moved recents things into a separate (and reusable) controler --- webclient/recents/recents.html | 53 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 webclient/recents/recents.html (limited to 'webclient/recents/recents.html') diff --git a/webclient/recents/recents.html b/webclient/recents/recents.html new file mode 100644 index 0000000000..9817d1acee --- /dev/null +++ b/webclient/recents/recents.html @@ -0,0 +1,53 @@ +
+ + + + + + + + + + + +
+ {{ room.room_display_name }} + + {{ (room.lastMsg.ts) | date:'MMM d HH:mm' }} +
+ +
+ {{ room.inviter }} invited you +
+ +
+
+ {{ room.lastMsg.user_id }} + {{ {"join": "joined", "leave": "left", "invite": "invited"}[room.lastMsg.content.membership] }} + {{ room.lastMsg.content.membership === "invite" ? (room.lastMsg.state_key || '') : '' }} +
+ +
+
+
+ {{ room.lastMsg.user_id }} : + + +
+ +
+ {{ room.lastMsg.user_id }} sent an image +
+ +
+ {{ room.lastMsg.content }} +
+
+
+ +
+ {{ room.lastMsg }} +
+
+
+
-- cgit 1.4.1 From 87190a9673cc6cf81b1fa54892c0d0b229c0c705 Mon Sep 17 00:00:00 2001 From: Emmanuel ROHEE Date: Wed, 27 Aug 2014 15:50:07 +0200 Subject: Sort recents in anti-chronological order --- webclient/index.html | 1 + webclient/recents/recents-filter.js | 47 +++++++++++++++++++++++++++++++++++++ webclient/recents/recents.html | 2 +- 3 files changed, 49 insertions(+), 1 deletion(-) create mode 100644 webclient/recents/recents-filter.js (limited to 'webclient/recents/recents.html') diff --git a/webclient/index.html b/webclient/index.html index f6d3744419..16f0e8ac5f 100644 --- a/webclient/index.html +++ b/webclient/index.html @@ -20,6 +20,7 @@ + diff --git a/webclient/recents/recents-filter.js b/webclient/recents/recents-filter.js new file mode 100644 index 0000000000..45653fca96 --- /dev/null +++ b/webclient/recents/recents-filter.js @@ -0,0 +1,47 @@ +/* + Copyright 2014 matrix.org + + 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'; + +angular.module('RecentsController') +.filter('orderRecents', function() { + return function(rooms) { + + // Transform the dict into an array + // The key, room_id, is already in value objects + var filtered = []; + angular.forEach(rooms, function(value, key) { + filtered.push( value ); + }); + + // And time sort them + // The room with the lastest message at first + filtered.sort(function (a, b) { + // Invite message does not have a body message nor ts + // Puth them at the top of the list + if (undefined === a.lastMsg) { + return -1; + } + else if (undefined === b.lastMsg) { + return 1; + } + else { + return b.lastMsg.ts - a.lastMsg.ts; + } + }); + return filtered; + }; +}); \ No newline at end of file diff --git a/webclient/recents/recents.html b/webclient/recents/recents.html index 9817d1acee..6b9abce02c 100644 --- a/webclient/recents/recents.html +++ b/webclient/recents/recents.html @@ -1,6 +1,6 @@
- +
{{ room.room_display_name }} -- cgit 1.4.1 From fb9661898d09c7a391abcc56a9c4b51d8065e491 Mon Sep 17 00:00:00 2001 From: Emmanuel ROHEE Date: Wed, 27 Aug 2014 16:24:23 +0200 Subject: BF: use room_id if there is no alias --- 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 6b9abce02c..6d2864ac97 100644 --- a/webclient/recents/recents.html +++ b/webclient/recents/recents.html @@ -1,6 +1,6 @@
- +
{{ room.room_display_name }} -- cgit 1.4.1 From d9155b6a25d706edb85706a1c0cff6dacbdc1640 Mon Sep 17 00:00:00 2001 From: Emmanuel ROHEE Date: Wed, 27 Aug 2014 17:20:41 +0200 Subject: Highlight the current room in the recents list --- webclient/app.css | 4 ++++ webclient/recents/recents-controller.js | 6 +++++- webclient/recents/recents.html | 5 ++++- webclient/room/room-controller.js | 3 +++ 4 files changed, 16 insertions(+), 2 deletions(-) (limited to 'webclient/recents/recents.html') diff --git a/webclient/app.css b/webclient/app.css index e2526dcbaa..8abdd1cb44 100644 --- a/webclient/app.css +++ b/webclient/app.css @@ -368,6 +368,10 @@ h1 { background-color: #f8f8ff; } +.recentsRoomSelected { + background-color: #eee; +} + .recentsRoomName { font-size: 16px; padding-top: 7px; diff --git a/webclient/recents/recents-controller.js b/webclient/recents/recents-controller.js index a9805fc38a..8f8b08d5bd 100644 --- a/webclient/recents/recents-controller.js +++ b/webclient/recents/recents-controller.js @@ -20,7 +20,11 @@ angular.module('RecentsController', ['matrixService', 'eventHandlerService']) .controller('RecentsController', ['$scope', 'matrixService', 'eventHandlerService', 'eventStreamService', function($scope, matrixService, eventHandlerService, eventStreamService) { $scope.rooms = {}; - + + // $scope of the parent where the recents component is included can override this value + // in order to highlight a specific room in the list + $scope.recentsSelectedRoomID; + $scope.$on(eventHandlerService.MEMBER_EVENT, function(ngEvent, event, isLive) { var config = matrixService.config(); if (event.state_key === config.user_id && event.content.membership === "invite") { diff --git a/webclient/recents/recents.html b/webclient/recents/recents.html index 6d2864ac97..6fda6c5c6b 100644 --- a/webclient/recents/recents.html +++ b/webclient/recents/recents.html @@ -1,6 +1,9 @@
- +
{{ room.room_display_name }} diff --git a/webclient/room/room-controller.js b/webclient/room/room-controller.js index f49deaa489..641ccddce7 100644 --- a/webclient/room/room-controller.js +++ b/webclient/room/room-controller.js @@ -327,6 +327,9 @@ angular.module('RoomController', ['ngSanitize', 'mUtilities']) var onInit2 = function() { eventHandlerService.reInitRoom($scope.room_id); + // Make recents highlight the current room + $scope.recentsSelectedRoomID = $scope.room_id; + // Join the room matrixService.join($scope.room_id).then( function() { -- cgit 1.4.1