mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2025-05-16 20:42:11 -04:00
Get user display name and avatar from the server rather than storing them in the local storage
This commit is contained in:
parent
b86d2a2d4f
commit
67f42b2f26
4 changed files with 68 additions and 21 deletions
|
@ -37,6 +37,11 @@ angular.module('HomeController', ['matrixService', 'eventHandlerService', 'Recen
|
|||
$scope.joinAlias = {
|
||||
room_alias: ""
|
||||
};
|
||||
|
||||
$scope.profile = {
|
||||
displayName: "",
|
||||
avatarUrl: ""
|
||||
};
|
||||
|
||||
var refresh = function() {
|
||||
|
||||
|
@ -108,6 +113,28 @@ angular.module('HomeController', ['matrixService', 'eventHandlerService', 'Recen
|
|||
};
|
||||
|
||||
$scope.onInit = function() {
|
||||
// Load profile data
|
||||
// Display name
|
||||
matrixService.getDisplayName($scope.config.user_id).then(
|
||||
function(response) {
|
||||
$scope.profile.displayName = response.data.displayname;
|
||||
$scope.profileOnServer.displayName = response.data.displayname;
|
||||
},
|
||||
function(error) {
|
||||
$scope.feedback = "Can't load display name";
|
||||
}
|
||||
);
|
||||
// Avatar
|
||||
matrixService.getProfilePictureUrl($scope.config.user_id).then(
|
||||
function(response) {
|
||||
$scope.profile.avatarUrl = response.data.avatar_url;
|
||||
$scope.profileOnServer.avatarUrl = response.data.avatar_url;
|
||||
},
|
||||
function(error) {
|
||||
$scope.feedback = "Can't load avatar URL";
|
||||
}
|
||||
);
|
||||
|
||||
refresh();
|
||||
};
|
||||
}]);
|
||||
|
|
|
@ -9,13 +9,13 @@
|
|||
<tr>
|
||||
<td>
|
||||
<div class="profile-avatar">
|
||||
<img ng-src="{{ config.avatarUrl || 'img/default-profile.jpg' }}"/>
|
||||
<img ng-src="{{ (null !== profile.avatarUrl) ? profile.avatarUrl : 'img/default-profile.jpg' }}"/>
|
||||
</div>
|
||||
</td>
|
||||
<td>
|
||||
<div id="user-ids">
|
||||
<div id="user-displayname">{{ config.displayName }}</div>
|
||||
<div>{{ config.user_id }}</div>
|
||||
<div id="user-displayname">{{ profile.displayName }}</div>
|
||||
<div>{{ config.user_id }}</div>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue