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

Commit

Permalink
small fix with localforage
Browse files Browse the repository at this point in the history
  • Loading branch information
pablorsk committed Jul 8, 2017
1 parent c607a7b commit b41d65f
Showing 1 changed file with 6 additions and 16 deletions.
22 changes: 6 additions & 16 deletions src/library/sources/store.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,11 @@ export class StoreService {

private checkIfIsTimeToClean() {
// check if is time to check cachestore
this.globalstore.getItem('_lastclean_time').then(success => {
if (success) {
if (Date.now() >= (success.time + 12 * 3600 * 1000)) {
// is time to check cachestore!
this.globalstore.setItem('_lastclean_time', { time: Date.now() });
this.checkAndDeleteOldElements();
}
} else {
this.globalstore.getItem('_lastclean_time', true).then(success => {
if (Date.now() >= (success.time + 12 * 3600 * 1000)) {
// is time to check cachestore!
this.globalstore.setItem('_lastclean_time', { time: Date.now() });
this.checkAndDeleteOldElements();
}
})
.catch(() => {
Expand All @@ -44,7 +40,6 @@ export class StoreService {
}
})
.catch( () => {} );
;
});
})
.catch( () => {} );
Expand All @@ -53,14 +48,9 @@ export class StoreService {
public getObjet(key: string): Promise<object> {
let deferred = this.$q.defer();

this.allstore.getItem('jsonapi.' + key)
this.allstore.getItem('jsonapi.' + key, true)
.then (success => {
// problem on localForage
if (success) {
deferred.resolve(success);
} else {
deferred.reject(success);
}
deferred.resolve(success);
})
.catch(error => {
deferred.reject(error);
Expand Down

0 comments on commit b41d65f

Please sign in to comment.