set bws url for each wallet
This commit is contained in:
parent
a75bbe6e45
commit
24609c6b15
6 changed files with 68 additions and 77 deletions
|
|
@ -118,7 +118,6 @@ angular.module('copayApp.controllers').controller('createController',
|
|||
configService.set(opts_, function(err) {
|
||||
if (err) console.log(err);
|
||||
$scope.$emit('Local/BWSUpdated');
|
||||
applicationService.restart();
|
||||
go.walletHome();
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -31,7 +31,6 @@ angular.module('copayApp.controllers').controller('importController',
|
|||
configService.set(opts, function(err) {
|
||||
if (err) return cb(err);
|
||||
$scope.$emit('Local/BWSUpdated');
|
||||
applicationService.restart();
|
||||
return cb(null);
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1005,11 +1005,6 @@ angular.module('copayApp.controllers').controller('indexController', function($r
|
|||
}, cb);
|
||||
});
|
||||
|
||||
$rootScope.$on('Local/BWSUpdated', function(event) {
|
||||
profileService.applyConfig();
|
||||
storageService.setCleanAndScanAddresses(function() {});
|
||||
});
|
||||
|
||||
$rootScope.$on('Local/WalletCompleted', function(event) {
|
||||
self.setFocusedWallet();
|
||||
go.walletHome();
|
||||
|
|
|
|||
|
|
@ -84,7 +84,6 @@ angular.module('copayApp.controllers').controller('joinController',
|
|||
configService.set(opts_, function(err) {
|
||||
if (err) console.log(err);
|
||||
$scope.$emit('Local/BWSUpdated');
|
||||
applicationService.restart();
|
||||
});
|
||||
|
||||
if (fc.isComplete() && (opts.mnemonic || opts.externalSource || opts.extendedPrivateKey)) {
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('copayApp.controllers').controller('preferencesBwsUrlController',
|
||||
function($scope, $log, configService, go, applicationService, profileService) {
|
||||
function($scope, $log, configService, go, applicationService, profileService, storageService) {
|
||||
this.error = null;
|
||||
this.success = null;
|
||||
|
||||
|
|
@ -42,8 +42,9 @@ angular.module('copayApp.controllers').controller('preferencesBwsUrlController',
|
|||
|
||||
configService.set(opts, function(err) {
|
||||
if (err) console.log(err);
|
||||
$scope.$emit('Local/BWSUpdated');
|
||||
storageService.setCleanAndScanAddresses(function() {
|
||||
applicationService.restart();
|
||||
});
|
||||
});
|
||||
};
|
||||
});
|
||||
|
|
|
|||
|
|
@ -48,26 +48,28 @@ angular.module('copayApp.services')
|
|||
});
|
||||
};
|
||||
|
||||
root.setWalletClients = function() {
|
||||
lodash.each(root.profile.credentials, function(credentials) {
|
||||
|
||||
root.setWalletClient = function(credentials) {
|
||||
if (root.walletClients[credentials.walletId] &&
|
||||
root.walletClients[credentials.walletId].started) {
|
||||
return;
|
||||
}
|
||||
|
||||
var config = configService.getSync();
|
||||
var defaults = configService.getDefaults();
|
||||
|
||||
bwcService.setBaseUrl(config.bws[credentials.walletId] || defaults.bws.url);
|
||||
bwcService.setTransports(['polling']);
|
||||
|
||||
var client = bwcService.getClient(JSON.stringify(credentials));
|
||||
root.walletClients[credentials.walletId] = client;
|
||||
client.removeAllListeners();
|
||||
|
||||
|
||||
client.on('reconnect', function() {
|
||||
if (root.focusedClient.credentials.walletId == client.credentials.walletId) {
|
||||
$log.debug('### Online');
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
client.on('reconnecting', function() {
|
||||
if (root.focusedClient.credentials.walletId == client.credentials.walletId) {
|
||||
$log.debug('### Offline');
|
||||
|
|
@ -104,25 +106,22 @@ angular.module('copayApp.services')
|
|||
return;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
root.setWalletClients = function(walletId) {
|
||||
var credentials = root.profile.credentials;
|
||||
lodash.each(credentials, function(credentials) {
|
||||
root.setWalletClient(credentials);
|
||||
});
|
||||
$rootScope.$emit('Local/WalletListUpdated');
|
||||
};
|
||||
|
||||
|
||||
root.applyConfig = function() {
|
||||
var config = configService.getSync();
|
||||
$log.debug('Applying preferences');
|
||||
bwcService.setBaseUrl(config.bws.url);
|
||||
bwcService.setTransports(['polling']);
|
||||
};
|
||||
|
||||
root.bindProfile = function(profile, cb) {
|
||||
root.profile = profile;
|
||||
|
||||
configService.get(function(err) {
|
||||
$log.debug('Preferences read');
|
||||
if (err) return cb(err);
|
||||
root.applyConfig();
|
||||
root.setWalletClients();
|
||||
storageService.getFocusedWalletId(function(err, focusedWalletId) {
|
||||
if (err) return cb(err);
|
||||
|
|
@ -415,7 +414,6 @@ angular.module('copayApp.services')
|
|||
root.create = function(opts, cb) {
|
||||
$log.info('Creating profile');
|
||||
configService.get(function(err) {
|
||||
root.applyConfig();
|
||||
root._createNewProfile(opts, function(err, p) {
|
||||
if (err) return cb(err);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue