Skip to content

Commit

Permalink
Follow API renaming. state -> presence. mtime_ago -> last_active_ago
Browse files Browse the repository at this point in the history
  • Loading branch information
Emmanuel ROHEE committed Sep 1, 2014
1 parent 74cffcf commit 0271e8e
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 16 deletions.
2 changes: 1 addition & 1 deletion webclient/app-filter.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ angular.module('matrixWebClient')
});

filtered.sort(function (a, b) {
return ((a["mtime_age"] || 10e10) > (b["mtime_age"] || 10e10) ? 1 : -1);
return ((a["last_active_ago"] || 10e10) > (b["last_active_ago"] || 10e10) ? 1 : -1);
});
return filtered;
};
Expand Down
25 changes: 12 additions & 13 deletions webclient/room/room-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -165,11 +165,11 @@ angular.module('RoomController', ['ngSanitize', 'mFileInput'])
var isNewMember = !(target_user_id in $scope.members);
if (isNewMember) {
// FIXME: why are we copying these fields around inside chunk?
if ("state" in chunk.content) {
chunk.presenceState = chunk.content.state; // why is this renamed?
if ("presence" in chunk.content) {
chunk.presence = chunk.content.presence;
}
if ("mtime_age" in chunk.content) {
chunk.mtime_age = chunk.content.mtime_age;
if ("last_active_ago" in chunk.content) {
chunk.last_active_ago = chunk.content.last_active_ago;
}
if ("displayname" in chunk.content) {
chunk.displayname = chunk.content.displayname;
Expand All @@ -188,11 +188,11 @@ angular.module('RoomController', ['ngSanitize', 'mFileInput'])
// selectively update membership and presence else it will nuke the picture and displayname too :/
var member = $scope.members[target_user_id];
member.membership = chunk.content.membership;
if ("state" in chunk.content) {
member.presenceState = chunk.content.state;
if ("presence" in chunk.content) {
member.presence = chunk.content.presence;
}
if ("mtime_age" in chunk.content) {
member.mtime_age = chunk.content.mtime_age;
if ("last_active_ago" in chunk.content) {
member.last_active_ago = chunk.content.last_active_ago;
}
}
};
Expand All @@ -211,13 +211,12 @@ angular.module('RoomController', ['ngSanitize', 'mFileInput'])
var member = $scope.members[chunk.content.user_id];

// XXX: why not just pass the chunk straight through?
if ("state" in chunk.content) {
member.presenceState = chunk.content.state;
if ("presence" in chunk.content) {
member.presence = chunk.content.presence;
}

if ("mtime_age" in chunk.content) {
// FIXME: should probably keep updating mtime_age in realtime like FB does
member.mtime_age = chunk.content.mtime_age;
if ("last_active_ago" in chunk.content) {
member.last_active_ago = chunk.content.last_active_ago;
}

// this may also contain a new display name or avatar url, so check.
Expand Down
4 changes: 2 additions & 2 deletions webclient/room/room.html
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
<img class="userAvatarGradient" src="img/gradient.png" title="{{ member.id }}" width="80" height="24"/>
<div class="userName">{{ member.displayname || member.id.substr(0, member.id.indexOf(':')) }}<br/>{{ member.displayname ? "" : member.id.substr(member.id.indexOf(':')) }}</div>
</td>
<td class="userPresence" ng-class="(member.presenceState === 'online' ? 'online' : (member.presenceState === 'unavailable' ? 'unavailable' : '')) + ' ' + (member.membership == 'invite' ? 'invited' : '')">
<span ng-show="member.mtime_age">{{ member.mtime_age + (now - member.last_updated) | duration }}<br/>ago</span>
<td class="userPresence" ng-class="(member.presence === 'online' ? 'online' : (member.presence === 'unavailable' ? 'unavailable' : '')) + ' ' + (member.membership == 'invite' ? 'invited' : '')">
<span ng-show="member.last_active_ago">{{ member.last_active_ago + (now - member.last_updated) | duration }}<br/>ago</span>
</td>
</table>
</div>
Expand Down

0 comments on commit 0271e8e

Please sign in to comment.