diff --git a/webclient/app-filter.js b/webclient/app-filter.js
index b8d3d2a0d8..e0e8130e45 100644
--- a/webclient/app-filter.js
+++ b/webclient/app-filter.js
@@ -103,7 +103,44 @@ angular.module('matrixWebClient')
for (var i in room.members) {
var member = room.members[i];
if (member.user_id !== matrixService.config().user_id) {
- roomName = member.content.displayname ? member.content.displayname : member.user_id;
+
+ if (member.user_id in $rootScope.presence) {
+ // If the user is available in presence, use the displayname there
+ // as it is the most uptodate
+ roomName = $rootScope.presence[member.user_id].content.displayname;
+ }
+ else if (member.content.displayname) {
+ roomName = member.content.displayname;
+ }
+ else {
+ roomName = member.user_id;
+ }
+ }
+ }
+ }
+ else if (1 === Object.keys(room.members).length) {
+ // The other member may be in the invite list, get all invited users
+ var invitedUserIDs = [];
+ for (var i in room.messages) {
+ var message = room.messages[i];
+ if ("m.room.member" === message.type && "invite" === message.membership) {
+ // Make sure there is no duplicate user
+ if (-1 === invitedUserIDs.indexOf(message.state_key)) {
+ invitedUserIDs.push(message.state_key);
+ }
+ }
+ }
+
+ // For now, only 1:1 room needs to be renamed. It means only 1 invited user
+ if (1 === invitedUserIDs.length) {
+ var userID = invitedUserIDs[0];
+
+ // Try to resolve his displayname in presence global data
+ if (userID in $rootScope.presence) {
+ roomName = $rootScope.presence[userID].content.displayname;
+ }
+ else {
+ roomName = member.user_id;
}
}
}
diff --git a/webclient/app.css b/webclient/app.css
index c27ec797a4..425d5bb11a 100755
--- a/webclient/app.css
+++ b/webclient/app.css
@@ -270,9 +270,9 @@ a:active { color: #000; }
.userAvatar .userPowerLevel {
position: absolute;
- bottom: 20px;
- height: 1px;
- background-color: red;
+ bottom: 0px;
+ height: 2px;
+ background-color: #f00;
}
.userPresence {
@@ -525,3 +525,13 @@ a:active { color: #000; }
font-size: 24px;
}
+#user-displayname-input {
+ width: 160px;
+ max-width: 155px;
+}
+
+#user-save-button {
+ width: 160px;
+ font-size: 14px;
+}
+
diff --git a/webclient/app.js b/webclient/app.js
index 9663ddf967..dac4f048cd 100644
--- a/webclient/app.js
+++ b/webclient/app.js
@@ -36,34 +36,27 @@ matrixWebClient.config(['$routeProvider', '$provide', '$httpProvider',
function($routeProvider, $provide, $httpProvider) {
$routeProvider.
when('/login', {
- templateUrl: 'login/login.html',
- controller: 'LoginController'
+ templateUrl: 'login/login.html'
}).
when('/register', {
- templateUrl: 'login/register.html',
- controller: 'RegisterController'
+ templateUrl: 'login/register.html'
}).
when('/room/:room_id_or_alias', {
- templateUrl: 'room/room.html',
- controller: 'RoomController'
+ templateUrl: 'room/room.html'
}).
when('/room/', { // room URL with room alias in it (ex: http://127.0.0.1:8000/#/room/#public:localhost:8080) will come here.
// The reason is that 2nd hash key breaks routeProvider parameters cutting so that the URL will not match with
// the previous '/room/:room_id_or_alias' URL rule
- templateUrl: 'room/room.html',
- controller: 'RoomController'
+ templateUrl: 'room/room.html'
}).
when('/', {
- templateUrl: 'home/home.html',
- controller: 'HomeController'
+ templateUrl: 'home/home.html'
}).
when('/settings', {
- templateUrl: 'settings/settings.html',
- controller: 'SettingsController'
+ templateUrl: 'settings/settings.html'
}).
when('/user/:user_matrix_id', {
- templateUrl: 'user/user.html',
- controller: 'UserController'
+ templateUrl: 'user/user.html'
}).
otherwise({
redirectTo: '/'
diff --git a/webclient/components/matrix/event-handler-service.js b/webclient/components/matrix/event-handler-service.js
index f248116914..d6a0600132 100644
--- a/webclient/components/matrix/event-handler-service.js
+++ b/webclient/components/matrix/event-handler-service.js
@@ -28,6 +28,7 @@ if typically all the $on method would do is update its own $scope.
*/
angular.module('eventHandlerService', [])
.factory('eventHandlerService', ['matrixService', '$rootScope', '$q', function(matrixService, $rootScope, $q) {
+ var ROOM_CREATE_EVENT = "ROOM_CREATE_EVENT";
var MSG_EVENT = "MSG_EVENT";
var MEMBER_EVENT = "MEMBER_EVENT";
var PRESENCE_EVENT = "PRESENCE_EVENT";
@@ -48,7 +49,7 @@ angular.module('eventHandlerService', [])
$rootScope.events.rooms[room_id].messages = [];
$rootScope.events.rooms[room_id].members = {};
}
- }
+ };
var resetRoomMessages = function(room_id) {
if ($rootScope.events.rooms[room_id]) {
@@ -56,6 +57,13 @@ angular.module('eventHandlerService', [])
}
};
+ var handleRoomCreate = function(event, isLiveEvent) {
+ initRoom(event.room_id);
+
+ // For now, we do not use the event data. Simply signal it to the app controllers
+ $rootScope.$broadcast(ROOM_CREATE_EVENT, event, isLiveEvent);
+ };
+
var handleMessage = function(event, isLiveEvent) {
initRoom(event.room_id);
@@ -110,6 +118,7 @@ angular.module('eventHandlerService', [])
};
return {
+ ROOM_CREATE_EVENT: ROOM_CREATE_EVENT,
MSG_EVENT: MSG_EVENT,
MEMBER_EVENT: MEMBER_EVENT,
PRESENCE_EVENT: PRESENCE_EVENT,
@@ -118,6 +127,9 @@ angular.module('eventHandlerService', [])
handleEvent: function(event, isLiveEvent) {
switch(event.type) {
+ case "m.room.create":
+ handleRoomCreate(event, isLiveEvent);
+ break;
case "m.room.message":
handleMessage(event, isLiveEvent);
break;
@@ -140,7 +152,7 @@ angular.module('eventHandlerService', [])
console.log(JSON.stringify(event, undefined, 4));
break;
}
- if (event.type.indexOf('m.call.') == 0) {
+ if (event.type.indexOf('m.call.') === 0) {
handleCallEvent(event, isLiveEvent);
}
},
diff --git a/webclient/home/home-controller.js b/webclient/home/home-controller.js
index 847918d5dc..f4ce3053ea 100644
--- a/webclient/home/home-controller.js
+++ b/webclient/home/home-controller.js
@@ -17,8 +17,8 @@ limitations under the License.
'use strict';
angular.module('HomeController', ['matrixService', 'eventHandlerService', 'RecentsController'])
-.controller('HomeController', ['$scope', '$location', 'matrixService',
- function($scope, $location, matrixService) {
+.controller('HomeController', ['$scope', '$location', 'matrixService', 'eventHandlerService',
+ function($scope, $location, matrixService, eventHandlerService) {
$scope.config = matrixService.config();
$scope.public_rooms = [];
@@ -72,7 +72,6 @@ angular.module('HomeController', ['matrixService', 'eventHandlerService', 'Recen
response.data.room_id);
matrixService.createRoomIdToAliasMapping(
response.data.room_id, response.data.room_alias);
- refresh();
},
function(error) {
$scope.feedback = "Failure: " + error.data;
@@ -133,6 +132,14 @@ angular.module('HomeController', ['matrixService', 'eventHandlerService', 'Recen
}
);
+ // Listen to room creation event in order to update the public rooms list
+ $scope.$on(eventHandlerService.ROOM_CREATE_EVENT, function(ngEvent, event, isLive) {
+ if (isLive) {
+ // As we do not know if this room is public, do a full list refresh
+ refresh();
+ }
+ });
+
refresh();
};
}]);
diff --git a/webclient/recents/recents-controller.js b/webclient/recents/recents-controller.js
index 947bd29de3..d7d3bf4053 100644
--- a/webclient/recents/recents-controller.js
+++ b/webclient/recents/recents-controller.js
@@ -47,6 +47,11 @@ angular.module('RecentsController', ['matrixService', 'eventHandlerService'])
$scope.rooms[event.room_id].lastMsg = event;
}
});
+ $scope.$on(eventHandlerService.ROOM_CREATE_EVENT, function(ngEvent, event, isLive) {
+ if (isLive) {
+ $scope.rooms[event.room_id] = event;
+ }
+ });
};
diff --git a/webclient/room/room-controller.js b/webclient/room/room-controller.js
index 1f90472c67..72c290ad73 100644
--- a/webclient/room/room-controller.js
+++ b/webclient/room/room-controller.js
@@ -163,8 +163,6 @@ angular.module('RoomController', ['ngSanitize', 'mFileInput'])
// set target_user_id to keep things clear
var target_user_id = chunk.state_key;
-
- var now = new Date().getTime();
var isNewMember = !(target_user_id in $scope.members);
if (isNewMember) {
@@ -174,6 +172,8 @@ angular.module('RoomController', ['ngSanitize', 'mFileInput'])
}
if ("last_active_ago" in chunk.content) {
chunk.last_active_ago = chunk.content.last_active_ago;
+ $scope.now = new Date().getTime();
+ chunk.last_updated = $scope.now;
}
if ("displayname" in chunk.content) {
chunk.displayname = chunk.content.displayname;
@@ -181,7 +181,6 @@ angular.module('RoomController', ['ngSanitize', 'mFileInput'])
if ("avatar_url" in chunk.content) {
chunk.avatar_url = chunk.content.avatar_url;
}
- chunk.last_updated = now;
$scope.members[target_user_id] = chunk;
if (target_user_id in $rootScope.presence) {
@@ -197,6 +196,8 @@ angular.module('RoomController', ['ngSanitize', 'mFileInput'])
}
if ("last_active_ago" in chunk.content) {
member.last_active_ago = chunk.content.last_active_ago;
+ $scope.now = new Date().getTime();
+ member.last_updated = $scope.now;
}
}
};
@@ -221,6 +222,8 @@ angular.module('RoomController', ['ngSanitize', 'mFileInput'])
if ("last_active_ago" in chunk.content) {
member.last_active_ago = chunk.content.last_active_ago;
+ $scope.now = new Date().getTime();
+ member.last_updated = $scope.now;
}
// this may also contain a new display name or avatar url, so check.
@@ -332,10 +335,6 @@ angular.module('RoomController', ['ngSanitize', 'mFileInput'])
eventHandlerService.waitForInitialSyncCompletion().then(
function() {
- // Some data has been retrieved from the iniialSync request
- // So, the relative time starts here
- $scope.now = new Date().getTime();
-
var needsToJoin = true;
// The room members is available in the data fetched by initialSync
diff --git a/webclient/settings/settings.html b/webclient/settings/settings.html
index a69a8de300..03927838d2 100644
--- a/webclient/settings/settings.html
+++ b/webclient/settings/settings.html
@@ -12,11 +12,12 @@
<div class="profile-avatar">
<img ng-src="{{ (null !== profile.avatarUrl) ? profile.avatarUrl : 'img/default-profile.png' }}" m-file-input="profile.avatarFile"/>
</div>
- <div id="user-ids">
- <input size="40" ng-model="profile.displayName" placeholder="Your display name"/>
+ <div>
+ <input id="user-displayname-input" size="40" ng-model="profile.displayName" placeholder="Your display name"/>
<br/>
- <button ng-disabled="(profile.displayName == profileOnServer.displayName) && (profile.avatarUrl == profileOnServer.avatarUrl)"
- ng-click="saveProfile()">Save</button>
+ <button id="user-save-button"
+ ng-disabled="(profile.displayName === profileOnServer.displayName) && (profile.avatarUrl === profileOnServer.avatarUrl)"
+ ng-click="saveProfile()">Save changes</button>
</div>
</form>
</div>
|