From 718c7d22becbc71cf1ed91a2286bb144ecdc556d Mon Sep 17 00:00:00 2001 From: Igor Zhukov Date: Fri, 30 Nov 2018 23:59:50 +0400 Subject: [PATCH] Fix userpic while profile not loaded --- app/js/controllers.js | 19 +++++++++++++++++-- app/partials/desktop/settings_modal.html | 2 +- app/partials/desktop/user_modal.html | 2 +- app/partials/mobile/settings_modal.html | 2 +- app/partials/mobile/user_modal.html | 2 +- 5 files changed, 21 insertions(+), 6 deletions(-) diff --git a/app/js/controllers.js b/app/js/controllers.js index 50920d53..97cc4f1b 100644 --- a/app/js/controllers.js +++ b/app/js/controllers.js @@ -3787,7 +3787,9 @@ angular.module('myApp.controllers', ['myApp.i18n']) $scope.settings = {notifications: true} - AppProfileManager.getProfile($scope.userID, $scope.override).then(function (userFull) { + var profilePromise = AppProfileManager.getProfile($scope.userID, $scope.override) + + profilePromise.then(function (userFull) { $scope.blocked = userFull.pFlags.blocked $scope.bot_info = userFull.bot_info $scope.rAbout = userFull.rAbout @@ -3811,6 +3813,12 @@ angular.module('myApp.controllers', ['myApp.i18n']) $rootScope.$broadcast('history_focus', {peerString: peerString}) } + $scope.openUserPic = function () { + profilePromise.then(function () { + $scope.openPhoto($scope.user.photo.photo_id, {p: $scope.userID}) + }) + } + $scope.flushHistory = function (justClear) { ErrorService.confirm({type: justClear ? 'HISTORY_FLUSH' : 'HISTORY_FLUSH_AND_DELETE'}).then(function () { AppMessagesManager.flushHistory($scope.userID, justClear).then(function () { @@ -4239,6 +4247,7 @@ angular.module('myApp.controllers', ['myApp.i18n']) }) .controller('SettingsModalController', function ($rootScope, $scope, $timeout, $modal, AppUsersManager, AppChatsManager, AppPhotosManager, MtpApiManager, Storage, NotificationsManager, MtpApiFileManager, PasswordManager, ApiUpdatesManager, ChangelogNotifyService, LayoutSwitchService, WebPushApiManager, AppRuntimeManager, ErrorService, _) { + $scope.profile = {} $scope.photo = {} $scope.version = Config.App.version @@ -4247,7 +4256,7 @@ angular.module('myApp.controllers', ['myApp.i18n']) $scope.profile = AppUsersManager.getUser(id) }) - MtpApiManager.invokeApi('users.getFullUser', { + var profilePromise = MtpApiManager.invokeApi('users.getFullUser', { id: {_: 'inputUserSelf'} }).then(function (userFullResult) { AppUsersManager.saveApiUser(userFullResult.user) @@ -4268,6 +4277,12 @@ angular.module('myApp.controllers', ['myApp.i18n']) var updatePasswordTimeout = false var stopped = false + $scope.openUserPic = function () { + profilePromise.then(function () { + $scope.openPhoto($scope.profile.photo.photo_id, {p: $scope.profile.id}) + }) + } + $scope.changePassword = function (options) { options = options || {} if (options.action == 'cancel_email') { diff --git a/app/partials/desktop/settings_modal.html b/app/partials/desktop/settings_modal.html index 9cba2ff7..a3be437a 100644 --- a/app/partials/desktop/settings_modal.html +++ b/app/partials/desktop/settings_modal.html @@ -14,7 +14,7 @@
- +
diff --git a/app/partials/desktop/user_modal.html b/app/partials/desktop/user_modal.html index f95960ce..7da1178a 100644 --- a/app/partials/desktop/user_modal.html +++ b/app/partials/desktop/user_modal.html @@ -11,7 +11,7 @@
- +
diff --git a/app/partials/mobile/settings_modal.html b/app/partials/mobile/settings_modal.html index ccd90897..0cc3d4d2 100644 --- a/app/partials/mobile/settings_modal.html +++ b/app/partials/mobile/settings_modal.html @@ -59,7 +59,7 @@
- +

diff --git a/app/partials/mobile/user_modal.html b/app/partials/mobile/user_modal.html index 921002c5..c3a2d3d0 100644 --- a/app/partials/mobile/user_modal.html +++ b/app/partials/mobile/user_modal.html @@ -52,7 +52,7 @@
- +