Browse Source

Fixed updateProfile

Close #1157
master
Igor Zhukov 9 years ago
parent
commit
4b9d23ce11
  1. 17
      app/js/controllers.js

17
app/js/controllers.js

@ -3748,9 +3748,11 @@ angular.module('myApp.controllers', ['myApp.i18n'])
id: {_: 'inputUserSelf'} id: {_: 'inputUserSelf'}
}).then(function (userFullResult) { }).then(function (userFullResult) {
AppUsersManager.saveApiUser(userFullResult.user); AppUsersManager.saveApiUser(userFullResult.user);
if (userFullResult.profile_photo) {
AppPhotosManager.savePhoto(userFullResult.profile_photo, { AppPhotosManager.savePhoto(userFullResult.profile_photo, {
user_id: userFullResult.user.id user_id: userFullResult.user.id
}); });
}
}); });
$scope.notify = {volume: 0.5}; $scope.notify = {volume: 0.5};
@ -4042,13 +4044,19 @@ angular.module('myApp.controllers', ['myApp.i18n'])
$scope.error = {}; $scope.error = {};
MtpApiManager.getUserID().then(function (id) { MtpApiManager.getUserID().then(function (id) {
$scope.profile = AppUsersManager.getUser(id); var user = AppUsersManager.getUser(id);
$scope.profile = {
first_name: user.first_name,
last_name: user.last_name
};
}); });
$scope.updateProfile = function () { $scope.updateProfile = function () {
$scope.profile.updating = true; $scope.profile.updating = true;
var flags = (1 << 0) | (1 << 1);
MtpApiManager.invokeApi('account.updateProfile', { MtpApiManager.invokeApi('account.updateProfile', {
flags: flags,
first_name: $scope.profile.first_name || '', first_name: $scope.profile.first_name || '',
last_name: $scope.profile.last_name || '' last_name: $scope.profile.last_name || ''
}).then(function (user) { }).then(function (user) {
@ -4084,7 +4092,10 @@ angular.module('myApp.controllers', ['myApp.i18n'])
$scope.error = {}; $scope.error = {};
MtpApiManager.getUserID().then(function (id) { MtpApiManager.getUserID().then(function (id) {
$scope.profile = angular.copy(AppUsersManager.getUser(id)); var user = AppUsersManager.getUser(id);
$scope.profile = {
username: user.username
};
}); });
$scope.updateUsername = function () { $scope.updateUsername = function () {

Loading…
Cancel
Save