Skip to content
This repository was archived by the owner on Aug 18, 2018. It is now read-only.

Commit b42d23e

Browse files
committed
better cache cleaner. small fix on demo (ui-router)
1 parent f233f9a commit b42d23e

2 files changed

Lines changed: 10 additions & 9 deletions

File tree

src/demo/containers/app.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ <h1>
99
<a class="nav-link" ui-sref="authors">Authors</a>
1010
</li>
1111
<li class="nav-item">
12-
<a class="nav-link" ui-sref="books">Books</a>
12+
<a class="nav-link" ui-sref="books({ filter: null })">Books</a>
1313
</li>
1414
</ul>
1515
</nav>

src/library/services/http-storage.service.ts

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,10 @@ export class HttpStorage {
1212
) {
1313
this.globalstore = $localForage.createInstance({ name: 'jsonapiglobal' });
1414
this.allstore = $localForage.createInstance({ name: 'allstore' });
15+
this.checkIfIsTimeToClean();
16+
}
1517

18+
private checkIfIsTimeToClean() {
1619
// check if is time to check store
1720
this.globalstore.getItem('_lastclean_time').then(success => {
1821
if (success) {
@@ -31,15 +34,13 @@ export class HttpStorage {
3134
this.allstore.keys().then(success => {
3235
angular.forEach(success, (key) => {
3336
// recorremos cada item y vemos si es tiempo de removerlo
34-
this.allstore.getItem(key).then(
35-
success2 => {
36-
// es tiempo de removerlo?
37-
if (Date.now() >= (success2._lastupdate_time + 12 * 3600 * 1000)) {
38-
// removemos!!
39-
this.allstore.removeItem(key);
40-
}
37+
this.allstore.getItem(key).then(success2 => {
38+
// es tiempo de removerlo?
39+
if (Date.now() >= (success2._lastupdate_time + 12 * 3600 * 1000)) {
40+
// removemos!!
41+
this.allstore.removeItem(key);
4142
}
42-
);
43+
});
4344
});
4445
});
4546
}

0 commit comments

Comments
 (0)