From 5ebd004a10c103078b4a99680636a2d6196e3d67 Mon Sep 17 00:00:00 2001 From: Kegan Dougal Date: Fri, 14 Nov 2014 15:30:49 +0000 Subject: [PATCH] Actually look for last_active_ago in the right place.. --- syweb/webclient/app-filter.js | 8 +- syweb/webclient/room/room.html | 6 +- syweb/webclient/test/unit/filters.spec.js | 196 +++++++++++++++------- 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 @@
{{ msg.__room_member.cnt.displayname || msg.user_id | mUserDisplayName:room_id:true }}
- - + 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 } },