Fix periodic fetching of apps/config/profile

All these are already fetched the first time in main.js

* Fetch apps periodically only in the apps view. This is mostly for the
  installationState. We can optimize this a bit more later depending on
  if any app is in non-running state.

* profile hardly changes, no need to fetch this over and over

* config hardly changes, but is fetched primarily for the update flag
This commit is contained in:
Girish Ramakrishnan
2018-01-08 09:45:16 -08:00
parent 50d396725e
commit af4296e40c
3 changed files with 30 additions and 22 deletions
+18 -8
View File
@@ -1,7 +1,7 @@
'use strict';
angular.module('Application').controller('AppsController', ['$scope', '$location', '$timeout', 'Client', 'ngTld', 'AppStore', function ($scope, $location, $timeout, Client, ngTld, AppStore) {
angular.module('Application').controller('AppsController', ['$scope', '$location', '$timeout', '$interval', 'Client', 'ngTld', 'AppStore', function ($scope, $location, $timeout, $interval, Client, ngTld, AppStore) {
$scope.HOST_PORT_MIN = 1024;
$scope.HOST_PORT_MAX = 65535;
$scope.installedApps = Client.getInstalledApps();
@@ -506,13 +506,23 @@ angular.module('Application').controller('AppsController', ['$scope', '$location
}
Client.onReady(function () {
if ($scope.user.admin) {
fetchUsers();
fetchGroups();
getDomains();
getMailConfig();
getBackupConfig();
}
Client.refreshInstalledApps(function (error) {
if (error) return console.error(error);
if ($scope.user.admin) {
fetchUsers();
fetchGroups();
getDomains();
getMailConfig();
getBackupConfig();
}
var refreshAppsTimer = $interval(Client.refreshInstalledApps.bind(Client), 5000);
$scope.$on('$destroy', function () {
$interval.cancel(refreshAppsTimer);
});
});
});
// setup all the dialog focus handling