From 67a64eaf3a598cad70af5810ae5a407633ec186f Mon Sep 17 00:00:00 2001 From: jdat82 Date: Sat, 13 Feb 2016 16:35:00 +0100 Subject: [PATCH] =?UTF-8?q?feature/settings=20=E2=80=94=20Capacity=20to=20?= =?UTF-8?q?empty=20cache=20on=20demand=20(http=20+=20images).?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/settings/settings.controller.js | 24 ++++++++++++++++++++---- app/settings/tab-settings.jade | 4 +++- 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/app/settings/settings.controller.js b/app/settings/settings.controller.js index d9c5a41..e2354e9 100644 --- a/app/settings/settings.controller.js +++ b/app/settings/settings.controller.js @@ -5,12 +5,14 @@ .module('app') .controller('SettingsController', SettingsController); - function SettingsController($log, $scope, $cordovaToast, defaultCacheName, CacheFactory, $ionicPopup, throwErr) { + function SettingsController($log, $scope, $cordovaToast, defaultCacheName, CacheFactory, + $ionicPopup, throwErr, ImgCache, $timeout) { var vm = this; vm.settings = { enableCache: true }; + vm.clearing = false; vm.clearCache = clearCache; activate(); @@ -24,7 +26,7 @@ }); } - function clearCache(){ + function clearCache() { var options = { title: 'Are you sure you want to clear all data cached ?', @@ -35,9 +37,23 @@ ///////////// - function clear(){ + function clear() { + vm.clearing = true; CacheFactory.get(defaultCacheName).removeAll(); - $log.info('Default cache is now empty'); + $log.info('HTTP cache is now empty'); + ImgCache.clearCache(ok, throwErr); + + ///////////// + + function ok() { + $scope.$apply(function () { + $log.info('Image cache is now empty'); + // So we could read something at least + $timeout(function () { + vm.clearing = false; + }, 500); + }); + } } } diff --git a/app/settings/tab-settings.jade b/app/settings/tab-settings.jade index 5f83f25..74ac812 100644 --- a/app/settings/tab-settings.jade +++ b/app/settings/tab-settings.jade @@ -4,4 +4,6 @@ ion-view(view-title='Settings') ion-toggle(ng-model='vm.settings.enableCache', toggle-class='toggle-positive') | Enable Cache ion-item(ng-click='vm.clearCache()') - button.button.button-assertive.button-small.button-block Empty cache \ No newline at end of file + button.button.button-assertive.button-small.button-block + span(ng-if='vm.clearing') Clearing… + span(ng-if='!vm.clearing') Clear cache