From 417ec605c8a48e92e75310aeaf7c95e9ac87559f Mon Sep 17 00:00:00 2001 From: Eduardo Robles Date: Mon, 25 Apr 2022 17:17:59 +0200 Subject: [PATCH] updating election cache after executing actions on an election because children election might also be affected (#281) --- avAdmin/admin-directives/dashboard/dashboard.js | 3 +++ avAdmin/elections-api-service.js | 5 +++++ 2 files changed, 8 insertions(+) diff --git a/avAdmin/admin-directives/dashboard/dashboard.js b/avAdmin/admin-directives/dashboard/dashboard.js index 412f0dd1..3e7710eb 100644 --- a/avAdmin/admin-directives/dashboard/dashboard.js +++ b/avAdmin/admin-directives/dashboard/dashboard.js @@ -165,6 +165,7 @@ angular.module('avAdmin') if (c.path === 'start') { + ElectionsApi.clearElectionCache(); Authmethod .changeAuthEvent(scope.election.id, 'started') .then( @@ -177,6 +178,7 @@ angular.module('avAdmin') ); } else if (c.path === 'stop') { + ElectionsApi.clearElectionCache(); Authmethod .changeAuthEvent(scope.election.id, 'stopped') .then( @@ -189,6 +191,7 @@ angular.module('avAdmin') ); } else { + ElectionsApi.clearElectionCache(); ElectionsApi .command(scope.election, c.path, c.method, c.data) .catch( diff --git a/avAdmin/elections-api-service.js b/avAdmin/elections-api-service.js index 0a5b675c..84842d4e 100644 --- a/avAdmin/elections-api-service.js +++ b/avAdmin/elections-api-service.js @@ -215,6 +215,11 @@ angular.module('avAdmin') electionsapi.cache[id] = election; }; + electionsapi.clearElectionCache = function () { + electionsapi.cache = {}; + electionsapi.permcache = {}; + }; + electionsapi.getElection = function(id, ignorecache, electionAuth) { var deferred = $q.defer();