Wrap all controller setup code with Client.onReady()

This ensures we don't rely on timing for execution against a non
ready Client instance
This commit is contained in:
Johannes Zellner
2016-07-27 16:34:36 +02:00
parent b13dd55fc6
commit dfc0598ec9
4 changed files with 33 additions and 28 deletions

View File

@@ -43,10 +43,6 @@ angular.module('Application').controller('ActivityController', ['$scope', '$loca
});
}
Client.onReady(function () {
fetchEventLogs();
});
$scope.showNextPage = function () {
$scope.currentPage++;
fetchEventLogs();
@@ -62,4 +58,8 @@ angular.module('Application').controller('ActivityController', ['$scope', '$loca
$scope.updateFilter = function () {
fetchEventLogs();
};
Client.onReady(function () {
fetchEventLogs();
});
}]);

View File

@@ -471,13 +471,15 @@ angular.module('Application').controller('AppsController', ['$scope', '$location
});
}
Client.refreshUserInfo(function (error) {
if (error) return console.error(error);
Client.onReady(function () {
Client.refreshUserInfo(function (error) {
if (error) return console.error(error);
if ($scope.user.admin) {
fetchUsers();
fetchGroups();
}
if ($scope.user.admin) {
fetchUsers();
fetchGroups();
}
});
});
// setup all the dialog focus handling

View File

@@ -373,28 +373,31 @@ angular.module('Application').controller('AppStoreController', ['$scope', '$loca
});
}
(function refresh() {
$scope.ready = false;
Client.onReady(function () {
(function refresh() {
$scope.ready = false;
getAppList(function (error, apps) {
if (error) {
console.error(error);
return $timeout(refresh, 1000);
}
getAppList(function (error, apps) {
if (error) {
console.error(error);
return $timeout(refresh, 1000);
}
$scope.apps = apps;
$scope.apps = apps;
// show install app dialog immediately if an app id was passed in the query
hashChangeListener();
// show install app dialog immediately if an app id was passed in the query
hashChangeListener();
if ($scope.user.admin) {
fetchUsers();
fetchGroups();
}
if ($scope.user.admin) {
fetchUsers();
fetchGroups();
}
$scope.ready = true;
});
})();
$scope.ready = true;
});
})();
});
$('#appInstallModal').on('hide.bs.modal', function () {
$location.path('/appstore', false).search({ version: undefined });

View File

@@ -389,7 +389,7 @@ angular.module('Application').controller('UsersController', ['$scope', '$locatio
});
}
refresh();
Client.onReady(refresh);
// setup all the dialog focus handling
['userAddModal', 'userRemoveModal', 'userEditModal', 'groupAddModal', 'groupRemoveModal'].forEach(function (id) {