Skip to content

Commit

Permalink
Reconfigure polling to prevent ghosting, meaningful error feedback
Browse files Browse the repository at this point in the history
We stop polling whenever a new request for resources has been made (or the component is destroyed)
After successfully grabbing these new resources, we begin polling on the successful call
This avoids the previous issue of stale polling
  • Loading branch information
AllenBW committed Jul 27, 2017
1 parent 615d42b commit 1c9844d
Showing 1 changed file with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ function ComponentController($state, ServicesState, Language, ListView, Chargeba
Language.fixState(ServicesState.services, vm.toolbarConfig);

resolveServices(vm.limit, 0);
Polling.start('serviceListPolling', pollUpdateServicesList, vm.pollingInterval);
};

function getCardConfig() {
Expand Down Expand Up @@ -357,6 +356,7 @@ function ComponentController($state, ServicesState, Language, ListView, Chargeba
}

function resolveServices(limit, offset, refresh) {
Polling.stop('serviceListPolling');
vm.loading = !refresh;
vm.offset = offset;
getFilterCount().then(() => {
Expand All @@ -367,6 +367,7 @@ function ComponentController($state, ServicesState, Language, ListView, Chargeba
});

function querySuccess(result) {
Polling.start('serviceListPolling', pollUpdateServicesList, vm.pollingInterval);
vm.loading = false;
vm.services = [];
var existingServices = (angular.isDefined(vm.servicesList) && refresh ? angular.copy(vm.servicesList) : []);
Expand Down Expand Up @@ -417,9 +418,9 @@ function ComponentController($state, ServicesState, Language, ListView, Chargeba
return (powerState !== 'on' && powerState !== 'off' ? powerStates.unknown : powerStates[powerState]);
}

function queryFailure(_error) {
function queryFailure(response) {
vm.loading = false;
EventNotifications.error(__('There was an error loading the services.'));
EventNotifications.error(__('There was an error loading the services. ') + response.data.error.message);
}
}

Expand Down

0 comments on commit 1c9844d

Please sign in to comment.