summary refs log tree commit diff
path: root/webclient/home
diff options
context:
space:
mode:
authorEmmanuel ROHEE <erohee@amdocs.com>2014-08-27 14:31:20 +0200
committerEmmanuel ROHEE <erohee@amdocs.com>2014-08-27 15:55:51 +0200
commitb1352f97acfd0a588eebd105b4ce757b97baef53 (patch)
treef6b1c99da815530ab53e1845a1202ae71853b230 /webclient/home
parentRename go() into goToPage() which is available from everywhere thanks to the ... (diff)
downloadsynapse-b1352f97acfd0a588eebd105b4ce757b97baef53.tar.xz
home/recents: show the last message of each message
Diffstat (limited to 'webclient/home')
-rw-r--r--webclient/home/home-controller.js4
-rw-r--r--webclient/home/home.html61
2 files changed, 57 insertions, 8 deletions
diff --git a/webclient/home/home-controller.js b/webclient/home/home-controller.js
index 3be7fca909..f0c2ccea2f 100644
--- a/webclient/home/home-controller.js
+++ b/webclient/home/home-controller.js
@@ -86,7 +86,9 @@ angular.module('HomeController', ['matrixService', 'mFileInput', 'mFileUpload',
                     $scope.rooms[data[i].room_id] = data[i];
 
                     // Create a shortcut for the last message of this room
-                    $scope.rooms[data[i].room_id].lastMsg = data[i].messages.chunk[0];
+                    if (data[i].messages && data[i].messages.chunk && data[i].messages.chunk[0]) {
+                        $scope.rooms[data[i].room_id].lastMsg = data[i].messages.chunk[0];
+                    }
                 }
 
                 var presence = response.data.presence;
diff --git a/webclient/home/home.html b/webclient/home/home.html
index 4084f4c388..49eb56a602 100644
--- a/webclient/home/home.html
+++ b/webclient/home/home.html
@@ -23,13 +23,60 @@
         </form>
     </div>
     
-    <h3>My rooms</h3>
-    
-    <div class="rooms" ng-repeat="(rm_id, room) in rooms">
-        <div>
-            <a href="#/room/{{ room.room_alias ? room.room_alias : rm_id }}" >{{ room.room_display_name }}</a> {{room.membership === 'invite' ? ' (invited)' : ''}}
-        </div>
-    </div>
+    <h3>Recents</h3>
+
+    <div class="recentsTableWrapper">
+    <table class="recentsTable">
+        <tbody ng-repeat="(rm_id, room) in rooms" ng-click="goToPage('room/' + (room.room_alias ? room.room_alias : rm_id) )" class ="recentsRoom" >
+            <tr>
+                <td class="recentsRoomName">
+                    {{ room.room_display_name }}
+                </td>
+                <td class="recentsRoomSummaryTS">
+                    {{ (room.lastMsg.ts) | date:'MMM d HH:mm' }}
+                </td>
+            </tr>
+
+            <tr>
+                <td colspan="2" class="recentsRoomSummary">
+
+                    <div ng-show="room.membership === 'invite'" >
+                        {{ room.inviter }} invited you
+                    </div>
+
+                    <div ng-hide="room.membership === 'invite'" ng-switch="room.lastMsg.type" >
+                         <div ng-switch-when="m.room.member">
+                            {{ room.lastMsg.user_id }}
+                            {{ {"join": "joined", "leave": "left", "invite": "invited"}[room.lastMsg.content.membership] }}
+                            {{ room.lastMsg.content.membership === "invite" ? (room.lastMsg.state_key || '') : '' }}
+                        </div>
+
+                        <div ng-switch-when="m.room.message">
+                            <div ng-switch="room.lastMsg.content.msgtype">
+                                <div ng-switch-when="m.text">
+                                    {{ room.lastMsg.user_id }} :
+                                    <span ng-bind-html="(room.lastMsg.content.body) | linky:'_blank'">
+                                    </span>
+                                </div>
+
+                                <div ng-switch-when="m.image">
+                                    {{ room.lastMsg.user_id }} sent an image
+                                </div>
+
+                                <div ng-switch-default>
+                                    {{ room.lastMsg.content }}
+                                </div>
+                            </div>
+                        </div>
+
+                        <div ng-switch-default>
+                            {{ room.lastMsg }}
+                        </div>
+                    </div>
+                </td>
+            </tr>
+        </tbody>
+    </table>
     <br/>
 
     <h3>Public rooms</h3>