Actually look for last_active_ago in the right place..

This commit is contained in:
Kegan Dougal 2014-11-14 15:30:49 +00:00
parent 459863bcff
commit 5ebd004a10
3 changed files with 140 additions and 70 deletions

View file

@ -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;

View file

@ -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'">

View file

@ -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
}
},