summary refs log tree commit diff
path: root/syweb
diff options
context:
space:
mode:
authorKegan Dougal <kegan@matrix.org>2014-11-14 15:30:49 +0000
committerKegan Dougal <kegan@matrix.org>2014-11-14 15:30:49 +0000
commit5ebd004a10c103078b4a99680636a2d6196e3d67 (patch)
treefba4bdaa82d409c6aa8252f2d9dcd1db8e731291 /syweb
parentRemove scope.members from RoomController and use modelService instead. This m... (diff)
downloadsynapse-5ebd004a10c103078b4a99680636a2d6196e3d67.tar.xz
Actually look for last_active_ago in the right place..
Diffstat (limited to 'syweb')
-rw-r--r--syweb/webclient/app-filter.js8
-rw-r--r--syweb/webclient/room/room.html6
-rw-r--r--syweb/webclient/test/unit/filters.spec.js196
3 files changed, 140 insertions, 70 deletions
diff --git a/syweb/webclient/app-filter.js b/syweb/webclient/app-filter.js
index 9162211066..b0971e8493 100644
--- a/syweb/webclient/app-filter.js
+++ b/syweb/webclient/app-filter.js
@@ -53,11 +53,11 @@ angular.module('matrixWebClient')
             b = b.user;
             
             var aLastActiveTS = 0, bLastActiveTS = 0;
-            if (a && undefined !== a.last_active_ago) {
-                aLastActiveTS = a.last_updated - a.last_active_ago;
+            if (a && a.event && a.event.content && a.event.content.last_active_ago !== undefined) {
+                aLastActiveTS = a.last_updated - a.event.content.last_active_ago;
             }
-            if (b && undefined !== b.last_active_ago) {
-                bLastActiveTS = b.last_updated - b.last_active_ago;
+            if (b && b.event && b.event.content && b.event.content.last_active_ago !== undefined) {
+                bLastActiveTS = b.last_updated - b.event.content.last_active_ago;
             }
             if (aLastActiveTS || bLastActiveTS) {
                 return bLastActiveTS - aLastActiveTS;
diff --git a/syweb/webclient/room/room.html b/syweb/webclient/room/room.html
index 62f6797d05..6151a4fea7 100644
--- a/syweb/webclient/room/room.html
+++ b/syweb/webclient/room/room.html
@@ -160,8 +160,10 @@
                     <div class="sender" ng-hide="room.events[$index - 1].user_id === msg.user_id || msg.user_id === state.user_id"> {{ msg.__room_member.cnt.displayname || msg.user_id | mUserDisplayName:room_id:true }}</div>
                 </td>
                 <td class="avatar">
-                    <!-- msg.__room_member.avatar_url is just backwards compat, and can be removed in the future. -->
-                    <img class="avatarImage" ng-src="{{ msg.__room_member.cnt.avatar_url || msg.__room_member.content.avatar_url || 'img/default-profile.png' }}" width="32" height="32" title="{{msg.user_id}}"
+                    <!--  room.now.members[msg.user_id].user.event.content.avatar_url is just backwards compat, and can be removed in the future. Synapse didn't used to
+                          send m.room.member updates when avatar urls changed, so the image which should be visible here just going off room state isn't visible. We fix
+                          this by reading off the m.presence url -->
+                    <img class="avatarImage" ng-src="{{ msg.__room_member.cnt.avatar_url || msg.__room_member.content.avatar_url || room.now.members[msg.user_id].user.event.content.avatar_url || 'img/default-profile.png' }}" width="32" height="32" title="{{msg.user_id}}"
                          ng-hide="room.events[$index - 1].user_id === msg.user_id || msg.user_id === state.user_id"/>
                 </td>
                 <td class="msg" ng-class="(!msg.content.membership && ('m.room.topic' !== msg.type && 'm.room.name' !== msg.type))? (msg.content.msgtype === 'm.emote' ? 'emote text' : 'text') : 'membership text'">
diff --git a/syweb/webclient/test/unit/filters.spec.js b/syweb/webclient/test/unit/filters.spec.js
index 54221e76db..e8944cbfc2 100644
--- a/syweb/webclient/test/unit/filters.spec.js
+++ b/syweb/webclient/test/unit/filters.spec.js
@@ -300,8 +300,11 @@ describe('orderMembersList filter', function() {
         var output = orderMembersList({
             "@a:example.com": {
                 user: {
-                    event: {},
-                    last_active_ago: 50,
+                    event: {
+                        content: {
+                            last_active_ago: 50
+                        }
+                    },
                     last_updated: 1415266943964
                 }
             }
@@ -309,8 +312,11 @@ describe('orderMembersList filter', function() {
         expect(output).toEqual([{
                 id: "@a:example.com",
                 user: {
-                    event: {},
-                    last_active_ago: 50,
+                    event: {
+                        content: {
+                            last_active_ago: 50
+                        }
+                    },
                     last_updated: 1415266943964
                 }
         }]);
@@ -320,22 +326,31 @@ describe('orderMembersList filter', function() {
         var output = orderMembersList({
             "@a:example.com": {
                 user: {
-                    event: {},
-                    last_active_ago: 1000,
+                    event: {
+                        content: {
+                            last_active_ago: 1000
+                        }
+                    },
                     last_updated: 1415266943964
                 }
             },
             "@b:example.com": {
                 user: {
-                    event: {},
-                    last_active_ago: 50,
+                    event: {
+                        content: {
+                            last_active_ago: 50
+                        }
+                    },
                     last_updated: 1415266943964
                 }
             },
             "@c:example.com": {
                 user: {
-                    event: {},
-                    last_active_ago: 99999,
+                    event: {
+                        content: {
+                            last_active_ago: 99999
+                        }
+                    },
                     last_updated: 1415266943964
                 }
             }
@@ -344,24 +359,33 @@ describe('orderMembersList filter', function() {
             {
                 id: "@b:example.com",
                 user: {
-                    event: {},
-                    last_active_ago: 50,
+                    event: {
+                        content: {
+                            last_active_ago: 50
+                        }
+                    },
                     last_updated: 1415266943964
                 }
             },
             {
                 id: "@a:example.com",
                 user: {
-                    event: {},
-                    last_active_ago: 1000,
+                    event: {
+                        content: {
+                            last_active_ago: 1000
+                        }
+                    },
                     last_updated: 1415266943964
                 }
             },
             {
                 id: "@c:example.com",
                 user: {
-                    event: {},
-                    last_active_ago: 99999,
+                    event: {
+                        content: {
+                            last_active_ago: 99999
+                        }
+                    },
                     last_updated: 1415266943964
                 }
             },
@@ -372,22 +396,31 @@ describe('orderMembersList filter', function() {
         var output = orderMembersList({
             "@a:example.com": {
                 user: {
-                    event: {},
-                    last_active_ago: 1000,
+                    event: {
+                        content: {
+                            last_active_ago: 1000
+                        }
+                    },
                     last_updated: 1415266943964
                 }
             },
             "@b:example.com": {
                 user: {
-                    event: {},
-                    last_active_ago: 1000,
+                    event: {
+                        content: {
+                            last_active_ago: 1000
+                        }
+                    },
                     last_updated: 1415266900000
                 }
             },
             "@c:example.com": {
                 user: {
-                    event: {},
-                    last_active_ago: 1000,
+                    event: {
+                        content: {
+                            last_active_ago: 1000
+                        }
+                    },
                     last_updated: 1415266943000
                 }
             }
@@ -396,24 +429,33 @@ describe('orderMembersList filter', function() {
             {
                 id: "@a:example.com",
                 user: {
-                    event: {},
-                    last_active_ago: 1000,
+                    event: {
+                        content: {
+                            last_active_ago: 1000
+                        }
+                    },
                     last_updated: 1415266943964
                 }
             },
             {
                 id: "@c:example.com",
                 user: {
-                    event: {},
-                    last_active_ago: 1000,
+                    event: {
+                        content: {
+                            last_active_ago: 1000
+                        }
+                    },
                     last_updated: 1415266943000
                 }
             },
             {
                 id: "@b:example.com",
                 user: {
-                    event: {},
-                    last_active_ago: 1000,
+                    event: {
+                        content: {
+                            last_active_ago: 1000
+                        }
+                    },
                     last_updated: 1415266900000
                 }
             },
@@ -425,22 +467,31 @@ describe('orderMembersList filter', function() {
         var output = orderMembersList({
             "@a:example.com": {
                 user: {
-                    event: {},
-                    last_active_ago: 1000,
+                    event: {
+                        content: {
+                            last_active_ago: 1000
+                        }
+                    },
                     last_updated: 1415266943000
                 }
             },
             "@b:example.com": {
                 user: {
-                    event: {},
-                    last_active_ago: 100000,
+                    event: {
+                        content: {
+                            last_active_ago: 100000
+                        }
+                    },
                     last_updated: 1415266943900
                 }
             },
             "@c:example.com": {
                 user: {
-                    event: {},
-                    last_active_ago: 1000,
+                    event: {
+                        content: {
+                            last_active_ago: 1000
+                        }
+                    },
                     last_updated: 1415266943964
                 }
             }
@@ -449,24 +500,33 @@ describe('orderMembersList filter', function() {
             {
                 id: "@c:example.com",
                 user: {
-                    event: {},
-                    last_active_ago: 1000,
+                    event: {
+                        content: {
+                            last_active_ago: 1000
+                        }
+                    },
                     last_updated: 1415266943964
                 }
             },
             {
                 id: "@a:example.com",
                 user: {
-                    event: {},
-                    last_active_ago: 1000,
+                    event: {
+                        content: {
+                            last_active_ago: 1000
+                        }
+                    },
                     last_updated: 1415266943000
                 }
             },
             {
                 id: "@b:example.com",
                 user: {
-                    event: {},
-                    last_active_ago: 100000,
+                    event: {
+                        content: {
+                            last_active_ago: 100000
+                        }
+                    },
                     last_updated: 1415266943900
                 }
             },
@@ -480,22 +540,26 @@ describe('orderMembersList filter', function() {
         var output = orderMembersList({
             "@a:example.com": {
                 user: {
-                    event: {},
-                    last_active_ago: 1000,
+                    event: {
+                        content: {
+                            last_active_ago: 1000
+                        }
+                    },
                     last_updated: 1415266943964
                 }
             },
             "@b:example.com": {
                 user: {
-                    event: {},
-                    last_active_ago: 100000,
+                    event: {
+                        content: {
+                            last_active_ago: 100000
+                        }
+                    },
                     last_updated: 1415266943964
                 }
             },
             "@c:example.com": {
                 user: {
-                    event: {},
-                    last_active_ago: undefined,
                     last_updated: 1415266943964
                 }
             }
@@ -504,24 +568,28 @@ describe('orderMembersList filter', function() {
             {
                 id: "@a:example.com",
                 user: {
-                    event: {},
-                    last_active_ago: 1000,
+                    event: {
+                        content: {
+                            last_active_ago: 1000
+                        }
+                    },
                     last_updated: 1415266943964
                 }
             },
             {
                 id: "@b:example.com",
                 user: {
-                    event: {},
-                    last_active_ago: 100000,
+                    event: {
+                        content: {
+                            last_active_ago: 100000
+                        }
+                    },
                     last_updated: 1415266943964
                 }
             },
             {
                 id: "@c:example.com",
                 user: {
-                    event: {},
-                    last_active_ago: undefined,
                     last_updated: 1415266943964
                 }
             },
@@ -536,10 +604,10 @@ describe('orderMembersList filter', function() {
                 user: {
                     event: {
                         content: {
-                            presence: "unavailable"
+                            presence: "unavailable",
+                            last_active_ago: undefined
                         }
                     },
-                    last_active_ago: undefined,
                     last_updated: 1415266943964
                 }
             },
@@ -547,10 +615,10 @@ describe('orderMembersList filter', function() {
                 user: {
                     event: {
                         content: {
-                            presence: "online"
+                            presence: "online",
+                            last_active_ago: undefined
                         }
                     },
-                    last_active_ago: undefined,
                     last_updated: 1415266943964,
                 }
             },
@@ -558,10 +626,10 @@ describe('orderMembersList filter', function() {
                 user: {
                     event: {
                         content: {
-                            presence: "offline"
+                            presence: "offline",
+                            last_active_ago: undefined
                         }
                     },
-                    last_active_ago: undefined,
                     last_updated: 1415266943964
                 }
             }
@@ -572,10 +640,10 @@ describe('orderMembersList filter', function() {
                 user: {
                     event: {
                         content: {
-                            presence: "online"
+                            presence: "online",
+                            last_active_ago: undefined
                         }
                     },
-                    last_active_ago: undefined,
                     last_updated: 1415266943964
                 }
             },
@@ -584,10 +652,10 @@ describe('orderMembersList filter', function() {
                 user: {
                     event: {
                         content: {
-                            presence: "unavailable"
+                            presence: "unavailable",
+                            last_active_ago: undefined
                         }
                     },
-                    last_active_ago: undefined,
                     last_updated: 1415266943964
                 }
             },
@@ -596,10 +664,10 @@ describe('orderMembersList filter', function() {
                 user: {
                     event: {
                         content: {
-                            presence: "offline"
+                            presence: "offline",
+                            last_active_ago: undefined
                         }
                     },
-                    last_active_ago: undefined,
                     last_updated: 1415266943964
                 }
             },