From 8f3416977419a350157cf82b69bea4a5ff28e094 Mon Sep 17 00:00:00 2001 From: Igor Zhukov Date: Wed, 22 Oct 2014 16:56:01 +0400 Subject: [PATCH] Fixed add contact from attachment Closes #492 --- app/js/controllers.js | 5 +++++ app/js/directives.js | 4 ++-- app/js/services.js | 3 ++- app/partials/desktop/message_attach_contact.html | 4 ++-- app/partials/mobile/message_attach_contact.html | 4 ++-- 5 files changed, 13 insertions(+), 7 deletions(-) diff --git a/app/js/controllers.js b/app/js/controllers.js index a3437570..6ed0ccf9 100644 --- a/app/js/controllers.js +++ b/app/js/controllers.js @@ -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') { diff --git a/app/js/directives.js b/app/js/directives.js index 80381a19..9dff598f 100644 --- a/app/js/directives.js +++ b/app/js/directives.js @@ -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)); }); } diff --git a/app/js/services.js b/app/js/services.js index 906c87e5..8a6b6602 100644 --- a/app/js/services.js +++ b/app/js/services.js @@ -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'), diff --git a/app/partials/desktop/message_attach_contact.html b/app/partials/desktop/message_attach_contact.html index 755e386d..907e7a98 100644 --- a/app/partials/desktop/message_attach_contact.html +++ b/app/partials/desktop/message_attach_contact.html @@ -1,7 +1,7 @@
- +
- +
diff --git a/app/partials/mobile/message_attach_contact.html b/app/partials/mobile/message_attach_contact.html index 755e386d..907e7a98 100644 --- a/app/partials/mobile/message_attach_contact.html +++ b/app/partials/mobile/message_attach_contact.html @@ -1,7 +1,7 @@
- +
- +