Fixed changing users sometimes not working
This commit is contained in:
parent
7fc0cd7631
commit
651fc4919f
1 changed files with 32 additions and 26 deletions
|
@ -19,21 +19,26 @@ App.Presenters.UserPresenter = function(
|
|||
var $messages = $el;
|
||||
var templates = {};
|
||||
var user;
|
||||
var userName;
|
||||
var userName = null;
|
||||
var activeTab;
|
||||
|
||||
function init(args, loaded) {
|
||||
promise.wait(util.promiseTemplate('user'))
|
||||
.then(function(template, response) {
|
||||
$messages = $el.find('.messages');
|
||||
templates.user = template;
|
||||
reinit(args, loaded);
|
||||
});
|
||||
}
|
||||
|
||||
function reinit(args, loaded) {
|
||||
if (args.userName !== userName) {
|
||||
userName = args.userName;
|
||||
topNavigationPresenter.select(auth.isLoggedIn(userName) ? 'my-account' : 'users');
|
||||
topNavigationPresenter.changeTitle(userName);
|
||||
|
||||
promise.wait(
|
||||
util.promiseTemplate('user'),
|
||||
api.get('/users/' + userName))
|
||||
.then(function(template, response) {
|
||||
$messages = $el.find('.messages');
|
||||
templates.user = template;
|
||||
|
||||
promise.wait(api.get('/users/' + userName))
|
||||
.then(function(response) {
|
||||
user = response.json;
|
||||
var extendedContext = _.extend(args, {user: user});
|
||||
|
||||
|
@ -42,7 +47,8 @@ App.Presenters.UserPresenter = function(
|
|||
[userAccountSettingsPresenter, _.extend({}, extendedContext, {target: '#account-settings-target'})],
|
||||
[userAccountRemovalPresenter, _.extend({}, extendedContext, {target: '#account-removal-target'})]],
|
||||
function() {
|
||||
reinit(args, loaded);
|
||||
initTabs(args);
|
||||
loaded();
|
||||
});
|
||||
|
||||
}).fail(function(response) {
|
||||
|
@ -50,12 +56,12 @@ App.Presenters.UserPresenter = function(
|
|||
messagePresenter.showError($messages, response.json && response.json.error || response);
|
||||
loaded();
|
||||
});
|
||||
}
|
||||
|
||||
function reinit(args, loaded) {
|
||||
} else {
|
||||
initTabs(args);
|
||||
loaded();
|
||||
}
|
||||
}
|
||||
|
||||
function initTabs(args) {
|
||||
activeTab = args.tab || 'basic-info';
|
||||
|
|
Loading…
Reference in a new issue