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-controller.js | 66 +++++++++++++++++++++++++++++++++ webclient/recents/recents.html | 53 ++++++++++++++++++++++++++ 2 files changed, 119 insertions(+) create mode 100644 webclient/recents/recents-controller.js create mode 100644 webclient/recents/recents.html (limited to 'webclient/recents') 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 }} +
+
+
+ -- cgit 1.4.1