Fixed updateProfile

Close #1157
This commit is contained in:
Igor Zhukov 2016-06-09 20:05:54 +03:00
parent 84b1fb0a43
commit 4b9d23ce11

View File

@ -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 () {