rm profileBound event

This commit is contained in:
Matias Alejo Garcia 2016-08-22 15:11:58 -03:00
commit 790237d5b1
No known key found for this signature in database
GPG key ID: 02470DB551277AB3

View file

@ -12,8 +12,7 @@ angular.module('copayApp.services')
var errors = bwcService.getErrors(); var errors = bwcService.getErrors();
var usePushNotifications = isCordova && !isWP; var usePushNotifications = isCordova && !isWP;
var FOREGROUND_UPDATE_PERIOD = 5; var UPDATE_PERIOD = 15;
var BACKGROUND_UPDATE_PERIOD = 30;
root.profile = null; root.profile = null;
@ -68,8 +67,6 @@ angular.module('copayApp.services')
wallet.on('notification', function(n) { wallet.on('notification', function(n) {
$log.debug('BWC Notification:', n); $log.debug('BWC Notification:', n);
$ionicHistory.clearCache();
notificationService.newBWCNotification(n, notificationService.newBWCNotification(n,
walletId, wallet.credentials.walletName); walletId, wallet.credentials.walletName);
@ -94,7 +91,7 @@ angular.module('copayApp.services')
$log.error('Could not init notifications err:', err); $log.error('Could not init notifications err:', err);
return; return;
} }
wallet.setNotificationsInterval(BACKGROUND_UPDATE_PERIOD); wallet.setNotificationsInterval(UPDATE_PERIOD);
}); });
@ -143,7 +140,6 @@ angular.module('copayApp.services')
} }
root.storeProfileIfDirty(); root.storeProfileIfDirty();
$rootScope.$emit('Local/ValidatingWalletEnded', walletId, isOK);
}); });
}, delay); }, delay);
}; };
@ -193,8 +189,6 @@ angular.module('copayApp.services')
totalBound += bound; totalBound += bound;
if (i == l) { if (i == l) {
$log.info('Bound ' + totalBound + ' out of ' + l + ' wallets'); $log.info('Bound ' + totalBound + ' out of ' + l + ' wallets');
if (totalBound)
$rootScope.$emit('Local/WalletListUpdated');
return cb(); return cb();
} }
}); });
@ -206,7 +200,15 @@ angular.module('copayApp.services')
root.pushNotificationsInit(); root.pushNotificationsInit();
root.isBound = true; root.isBound = true;
$rootScope.$emit('Local/ProfileBound');
lodash.each(root._queue, function(x) {
$timeout(function() {
return x();
}, 1);
});
root._queue = [];
root.isDisclaimerAccepted(function(val) { root.isDisclaimerAccepted(function(val) {
if (!val) { if (!val) {
@ -219,6 +221,15 @@ angular.module('copayApp.services')
}); });
}; };
root._queue = [];
root.whenAvailable = function(cb) {
if (!root.isBound) {
root._queue.push(cb);
return;
}
return cb();
};
root.pushNotificationsInit = function() { root.pushNotificationsInit = function() {
var defaults = configService.getDefaults(); var defaults = configService.getDefaults();
var push = pushNotificationsService.init(root.wallet); var push = pushNotificationsService.init(root.wallet);
@ -436,14 +447,9 @@ angular.module('copayApp.services')
if (err) $log.warn(err); if (err) $log.warn(err);
}); });
storageService.storeProfile(root.profile, function(err) {
$timeout(function() { if (err) return cb(err);
$rootScope.$emit('Local/WalletListUpdated'); return cb();
storageService.storeProfile(root.profile, function(err) {
if (err) return cb(err);
return cb();
});
}); });
}; };
@ -479,7 +485,6 @@ angular.module('copayApp.services')
root.runValidation(client); root.runValidation(client);
root.bindWalletClient(client); root.bindWalletClient(client);
$rootScope.$emit('Local/WalletListUpdated', client);
var saveBwsUrl = function(cb) { var saveBwsUrl = function(cb) {
var defaults = configService.getDefaults(); var defaults = configService.getDefaults();