Add localforage, basic cache service
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
import Service from '@ember/service';
|
||||
import * as localforage from 'localforage';
|
||||
|
||||
function createStore(name) {
|
||||
return localforage.createInstance({ name: `kredits:${name}` });
|
||||
}
|
||||
|
||||
export default class BrowserCacheService extends Service {
|
||||
|
||||
constructor() {
|
||||
super(...arguments);
|
||||
this.stores = {
|
||||
contributors: createStore('contributors'),
|
||||
contributions: createStore('contributions')
|
||||
}
|
||||
}
|
||||
|
||||
get contributors() {
|
||||
return this.stores.contributors;
|
||||
}
|
||||
|
||||
get contributions() {
|
||||
return this.stores.contributions;
|
||||
}
|
||||
}
|
||||
@@ -230,7 +230,7 @@ export default Service.extend({
|
||||
},
|
||||
|
||||
getContributions () {
|
||||
return this.kredits.Contribution.all({page: {size: 200}})
|
||||
return this.kredits.Contribution.all({page: {size: 30}})
|
||||
.then(contributions => {
|
||||
return contributions.map(contribution => {
|
||||
contribution.contributor = this.contributors.findBy('id', contribution.contributorId.toString());
|
||||
|
||||
Reference in New Issue
Block a user