Add network namespace for browser cache
We want to be able to cache data from multiple networks side-by-side, without them interfering with each other.
This commit is contained in:
@@ -1,8 +1,10 @@
|
|||||||
import Service from '@ember/service';
|
import Service from '@ember/service';
|
||||||
import * as localforage from 'localforage';
|
import * as localforage from 'localforage';
|
||||||
|
import config from 'kredits-web/config/environment';
|
||||||
|
|
||||||
function createStore(name) {
|
function createStore(name) {
|
||||||
return localforage.createInstance({ name: `kredits:${name}` });
|
const networkName = config.web3RequiredNetwork || 'custom';
|
||||||
|
return localforage.createInstance({ name: `kredits:${networkName}:${name}` });
|
||||||
}
|
}
|
||||||
|
|
||||||
export default class BrowserCacheService extends Service {
|
export default class BrowserCacheService extends Service {
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ module('Unit | Service | browser-cache', function(hooks) {
|
|||||||
|
|
||||||
test('creates kredits data stores', function(assert) {
|
test('creates kredits data stores', function(assert) {
|
||||||
let cache = this.owner.lookup('service:browser-cache');
|
let cache = this.owner.lookup('service:browser-cache');
|
||||||
assert.equal(cache.contributors._config.name, "kredits:contributors");
|
assert.equal(cache.contributors._config.name, "kredits:rinkeby:contributors");
|
||||||
assert.equal(cache.contributions._config.name, "kredits:contributions");
|
assert.equal(cache.contributions._config.name, "kredits:rinkeby:contributions");
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user