From 308c9273fadefd072f157620225515eb7395633d Mon Sep 17 00:00:00 2001 From: Emmanuel ROHEE Date: Wed, 27 Aug 2014 15:09:16 +0200 Subject: [PATCH] Moved recents things into a separate (and reusable) controler --- webclient/app.js | 1 + webclient/home/home-controller.js | 68 ++----------------------- webclient/home/home.html | 54 +------------------- webclient/index.html | 1 + webclient/recents/recents-controller.js | 66 ++++++++++++++++++++++++ webclient/recents/recents.html | 53 +++++++++++++++++++ 6 files changed, 126 insertions(+), 117 deletions(-) create mode 100644 webclient/recents/recents-controller.js create mode 100644 webclient/recents/recents.html diff --git a/webclient/app.js b/webclient/app.js index 6cd50c5e54..1d5503ebc0 100644 --- a/webclient/app.js +++ b/webclient/app.js @@ -20,6 +20,7 @@ var matrixWebClient = angular.module('matrixWebClient', [ 'LoginController', 'RoomController', 'HomeController', + 'RecentsController', 'SettingsController', 'UserController', 'matrixService', diff --git a/webclient/home/home-controller.js b/webclient/home/home-controller.js index f882801e76..e8e91eede7 100644 --- a/webclient/home/home-controller.js +++ b/webclient/home/home-controller.js @@ -16,12 +16,11 @@ limitations under the License. 'use strict'; -angular.module('HomeController', ['matrixService', 'eventHandlerService']) +angular.module('HomeController', ['matrixService', 'eventHandlerService', 'RecentsController']) .controller('HomeController', ['$scope', '$location', 'matrixService', 'eventHandlerService', 'eventStreamService', function($scope, $location, matrixService, eventHandlerService, eventStreamService) { $scope.config = matrixService.config(); - $scope.rooms = {}; $scope.public_rooms = []; $scope.newRoomId = ""; $scope.feedback = ""; @@ -32,77 +31,18 @@ angular.module('HomeController', ['matrixService', 'eventHandlerService']) }; $scope.goToRoom = { - room_id: "", + room_id: "" }; $scope.joinAlias = { - room_alias: "", - }; - - $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; - } - }); - - var assignRoomAliases = function(data) { - for (var i=0; i

Recents

- -
- - - - - - - - - - - -
- {{ 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 }} -
-
-
+

Public rooms

diff --git a/webclient/index.html b/webclient/index.html index 86dbb65e1e..f6d3744419 100644 --- a/webclient/index.html +++ b/webclient/index.html @@ -19,6 +19,7 @@ + diff --git a/webclient/recents/recents-controller.js b/webclient/recents/recents-controller.js new file mode 100644 index 0000000000..a9805fc38a --- /dev/null +++ b/webclient/recents/recents-controller.js @@ -0,0 +1,66 @@ +/* + 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', ['matrixService', 'eventHandlerService']) +.controller('RecentsController', ['$scope', 'matrixService', 'eventHandlerService', 'eventStreamService', + function($scope, matrixService, eventHandlerService, eventStreamService) { + $scope.rooms = {}; + + $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; + } + }); + + var refresh = function() { + // List all rooms joined or been invited to + matrixService.rooms(1, false).then( + function(response) { + var data = matrixService.assignRoomAliases(response.data.rooms); + for (var i=0; i + + + + + + + + + + + +
+ {{ 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 }} +
+
+
+