Merge pull request #2672 from coreos-inc/FIX-user-service-async
fix(user-service): make sync calls to update user async
This commit is contained in:
commit
ca5f588c44
1 changed files with 18 additions and 19 deletions
|
@ -3,9 +3,9 @@
|
||||||
* about the user.
|
* about the user.
|
||||||
*/
|
*/
|
||||||
angular.module('quay')
|
angular.module('quay')
|
||||||
.factory('UserService', ['ApiService', 'CookieService', '$rootScope', 'Config', '$location',
|
.factory('UserService', ['ApiService', 'CookieService', '$rootScope', 'Config', '$location', '$timeout',
|
||||||
|
|
||||||
function(ApiService, CookieService, $rootScope, Config, $location) {
|
function(ApiService, CookieService, $rootScope, Config, $location, $timeout) {
|
||||||
var userResponse = {
|
var userResponse = {
|
||||||
verified: false,
|
verified: false,
|
||||||
anonymous: true,
|
anonymous: true,
|
||||||
|
@ -25,10 +25,14 @@ function(ApiService, CookieService, $rootScope, Config, $location) {
|
||||||
|
|
||||||
userService.updateUserIn = function(scope, opt_callback) {
|
userService.updateUserIn = function(scope, opt_callback) {
|
||||||
scope.$watch(function () { return userService.currentUser(); }, function (currentUser) {
|
scope.$watch(function () { return userService.currentUser(); }, function (currentUser) {
|
||||||
scope.user = currentUser;
|
if (currentUser) {
|
||||||
if (opt_callback) {
|
$timeout(function(){
|
||||||
opt_callback(currentUser);
|
scope.user = currentUser;
|
||||||
}
|
if (opt_callback) {
|
||||||
|
opt_callback(currentUser);
|
||||||
|
}
|
||||||
|
}, 0, false);
|
||||||
|
};
|
||||||
}, true);
|
}, true);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -185,25 +189,20 @@ function(ApiService, CookieService, $rootScope, Config, $location) {
|
||||||
var deleteNamespaceItself = function() {
|
var deleteNamespaceItself = function() {
|
||||||
info.progress = 1;
|
info.progress = 1;
|
||||||
info.progressMessage = 'Deleting namespace...';
|
info.progressMessage = 'Deleting namespace...';
|
||||||
|
var cb = function(resp) {
|
||||||
if (info.user) {
|
userService.load(function(currentUser) {
|
||||||
ApiService.deleteCurrentUser().then(function(resp) {
|
|
||||||
// Reload the user.
|
|
||||||
userService.load();
|
|
||||||
callback(true);
|
callback(true);
|
||||||
$location.path('/');
|
$location.path('/');
|
||||||
}, errorDisplay);
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (info.user) {
|
||||||
|
ApiService.deleteCurrentUser().then(cb, errorDisplay)
|
||||||
} else {
|
} else {
|
||||||
var delParams = {
|
var delParams = {
|
||||||
'orgname': info.organization.name
|
'orgname': info.organization.name
|
||||||
};
|
};
|
||||||
|
ApiService.deleteAdminedOrganization(null, delParams).then(cb, errorDisplay);
|
||||||
ApiService.deleteAdminedOrganization(null, delParams).then(function(resp) {
|
|
||||||
// Reload the user.
|
|
||||||
userService.load();
|
|
||||||
callback(true);
|
|
||||||
$location.path('/');
|
|
||||||
}, errorDisplay);
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Reference in a new issue