Add localforage, basic cache service

This commit is contained in:
2020-05-27 12:59:37 +02:00
parent c57d4162d7
commit f996c89dfe
5 changed files with 69 additions and 1 deletions
+25
View File
@@ -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;
}
}
+1 -1
View File
@@ -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());