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

Commit b41d65f

Browse files
committed
small fix with localforage
1 parent c607a7b commit b41d65f

File tree

1 file changed

+6
-16
lines changed

1 file changed

+6
-16
lines changed

src/library/sources/store.service.ts

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,11 @@ export class StoreService {
1616

1717
private checkIfIsTimeToClean() {
1818
// check if is time to check cachestore
19-
this.globalstore.getItem('_lastclean_time').then(success => {
20-
if (success) {
21-
if (Date.now() >= (success.time + 12 * 3600 * 1000)) {
22-
// is time to check cachestore!
23-
this.globalstore.setItem('_lastclean_time', { time: Date.now() });
24-
this.checkAndDeleteOldElements();
25-
}
26-
} else {
19+
this.globalstore.getItem('_lastclean_time', true).then(success => {
20+
if (Date.now() >= (success.time + 12 * 3600 * 1000)) {
21+
// is time to check cachestore!
2722
this.globalstore.setItem('_lastclean_time', { time: Date.now() });
23+
this.checkAndDeleteOldElements();
2824
}
2925
})
3026
.catch(() => {
@@ -44,7 +40,6 @@ export class StoreService {
4440
}
4541
})
4642
.catch( () => {} );
47-
;
4843
});
4944
})
5045
.catch( () => {} );
@@ -53,14 +48,9 @@ export class StoreService {
5348
public getObjet(key: string): Promise<object> {
5449
let deferred = this.$q.defer();
5550

56-
this.allstore.getItem('jsonapi.' + key)
51+
this.allstore.getItem('jsonapi.' + key, true)
5752
.then (success => {
58-
// problem on localForage
59-
if (success) {
60-
deferred.resolve(success);
61-
} else {
62-
deferred.reject(success);
63-
}
53+
deferred.resolve(success);
6454
})
6555
.catch(error => {
6656
deferred.reject(error);

0 commit comments

Comments
 (0)