Skip to content

Commit 67a64ea

Browse files
committed
feature/settings — Capacity to empty cache on demand (http + images).
1 parent 43f2cca commit 67a64ea

File tree

2 files changed

+23
-5
lines changed

2 files changed

+23
-5
lines changed

app/settings/settings.controller.js

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,14 @@
55
.module('app')
66
.controller('SettingsController', SettingsController);
77

8-
function SettingsController($log, $scope, $cordovaToast, defaultCacheName, CacheFactory, $ionicPopup, throwErr) {
8+
function SettingsController($log, $scope, $cordovaToast, defaultCacheName, CacheFactory,
9+
$ionicPopup, throwErr, ImgCache, $timeout) {
910

1011
var vm = this;
1112
vm.settings = {
1213
enableCache: true
1314
};
15+
vm.clearing = false;
1416
vm.clearCache = clearCache;
1517

1618
activate();
@@ -24,7 +26,7 @@
2426
});
2527
}
2628

27-
function clearCache(){
29+
function clearCache() {
2830

2931
var options = {
3032
title: 'Are you sure you want to clear all data cached ?',
@@ -35,9 +37,23 @@
3537

3638
/////////////
3739

38-
function clear(){
40+
function clear() {
41+
vm.clearing = true;
3942
CacheFactory.get(defaultCacheName).removeAll();
40-
$log.info('Default cache is now empty');
43+
$log.info('HTTP cache is now empty');
44+
ImgCache.clearCache(ok, throwErr);
45+
46+
/////////////
47+
48+
function ok() {
49+
$scope.$apply(function () {
50+
$log.info('Image cache is now empty');
51+
// So we could read something at least
52+
$timeout(function () {
53+
vm.clearing = false;
54+
}, 500);
55+
});
56+
}
4157
}
4258

4359
}

app/settings/tab-settings.jade

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,6 @@ ion-view(view-title='Settings')
44
ion-toggle(ng-model='vm.settings.enableCache', toggle-class='toggle-positive')
55
| Enable Cache
66
ion-item(ng-click='vm.clearCache()')
7-
button.button.button-assertive.button-small.button-block Empty cache
7+
button.button.button-assertive.button-small.button-block
8+
span(ng-if='vm.clearing') Clearing…
9+
span(ng-if='!vm.clearing') Clear cache

0 commit comments

Comments
 (0)