Fixed add contact from attachment

Closes #492
This commit is contained in:
Igor Zhukov 2014-10-22 16:56:01 +04:00
parent 4a3463eefd
commit 8f34169774
5 changed files with 13 additions and 7 deletions

View File

@ -1811,6 +1811,11 @@ angular.module('myApp.controllers', ['myApp.i18n'])
MtpApiManager.invokeApi('users.getFullUser', {
id: AppUsersManager.getUserInput($scope.userID)
}).then(function (userFullResult) {
if ($scope.override && !userFullResult.user.phone) {
userFullResult.user.phone = $scope.override.phone_number;
userFullResult.user.first_name = $scope.override.first_name;
userFullResult.user.last_name = $scope.override.last_name;
}
AppUsersManager.saveApiUser(userFullResult.user);
AppPhotosManager.savePhoto(userFullResult.profile_photo);
if (userFullResult.profile_photo._ != 'photoEmpty') {

View File

@ -1767,7 +1767,7 @@ angular.module('myApp.directives', ['myApp.filters'])
if (element[0].tagName == 'A') {
element.on('click', function () {
$rootScope.openUser(userID);
$rootScope.openUser(userID, attrs.userOverride && $scope.$eval(attrs.userOverride));
});
}
if (attrs.color && $scope.$eval(attrs.color)) {
@ -1840,7 +1840,7 @@ angular.module('myApp.directives', ['myApp.filters'])
if (element[0].tagName == 'A') {
element.on('click', function (e) {
$rootScope.openUser($scope.userID);
$rootScope.openUser($scope.userID, attrs.userOverride && $scope.$eval(attrs.userOverride));
});
}

View File

@ -184,9 +184,10 @@ angular.module('myApp.services', ['myApp.i18n'])
return user;
}
function openUser (userID, accessHash) {
function openUser (userID, override) {
var scope = $rootScope.$new();
scope.userID = userID;
scope.override = override || {};
var modalInstance = $modal.open({
templateUrl: templateUrl('user_modal'),

View File

@ -1,7 +1,7 @@
<div>
<a class="im_message_contact_photo pull-left" my-user-photolink="historyMessage.media.user_id" img-class="im_message_contact_photo"></a>
<a class="im_message_contact_photo pull-left" my-user-photolink="historyMessage.media.user_id" img-class="im_message_contact_photo" user-override="historyMessage.media"></a>
<div class="im_message_contact_name" ng-switch="historyMessage.media.user_id > 0">
<a ng-switch-when="true" my-user-link="historyMessage.media.user_id"></a>
<a ng-switch-when="true" my-user-link="historyMessage.media.user_id" user-override="historyMessage.media"></a>
<span ng-switch-default ng-bind-html="::historyMessage.media.rFullName"></span>
</div>
<div class="im_message_contact_phone" ng-bind="::historyMessage.media.phone_number | phoneNumber"></div>

View File

@ -1,7 +1,7 @@
<div>
<a class="im_message_contact_photo pull-left" my-user-photolink="historyMessage.media.user_id" img-class="im_message_contact_photo"></a>
<a class="im_message_contact_photo pull-left" my-user-photolink="historyMessage.media.user_id" img-class="im_message_contact_photo" user-override="historyMessage.media"></a>
<div class="im_message_contact_name" ng-switch="historyMessage.media.user_id > 0">
<a ng-switch-when="true" my-user-link="historyMessage.media.user_id"></a>
<a ng-switch-when="true" my-user-link="historyMessage.media.user_id" user-override="historyMessage.media"></a>
<span ng-switch-default ng-bind-html="::historyMessage.media.rFullName"></span>
</div>
<div class="im_message_contact_phone" ng-bind="::historyMessage.media.phone_number | phoneNumber"></div>