mirror of https://github.com/embarklabs/embark.git
simplify add set providers; validation can be done on the client isde
This commit is contained in:
parent
e07d06fa4c
commit
c3fc614cd8
|
@ -26,23 +26,13 @@ class Storage {
|
|||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the code to call setProviders in embarkjs after embark is ready
|
||||
*
|
||||
* @returns {void}
|
||||
*/
|
||||
addSetProviders() {
|
||||
const self = this;
|
||||
// filter list of dapp connections based on available_providers set in config
|
||||
let hasSwarm = _.contains(this.storageConfig.available_providers, 'swarm'); // don't need to eval this in every loop iteration
|
||||
// contains valid dapp storage providers
|
||||
this._validDappProviders = _.filter(this.storageConfig.dappConnection, (conn) => {
|
||||
return _.contains(self.storageConfig.available_providers, conn.provider) || (conn === '$BZZ' && hasSwarm);
|
||||
});
|
||||
|
||||
let code = `\nEmbarkJS.Storage.setProviders(${JSON.stringify(this._validDappProviders)});`;
|
||||
let code = `\nEmbarkJS.Storage.setProviders(${JSON.stringify(this.storageConfig.dappConnection)});`;
|
||||
|
||||
let shouldInit = (storageConfig) => {
|
||||
return (this._validDappProviders !== undefined && this._validDappProviders.length > 0 && storageConfig.enabled === true);
|
||||
return storageConfig.enabled;
|
||||
};
|
||||
|
||||
this.embark.addProviderInit('storage', code, shouldInit);
|
||||
|
|
Loading…
Reference in New Issue