Merge pull request #2118 from matiu/pin

Pin
This commit is contained in:
Gustavo Maximiliano Cortez 2014-12-12 11:50:43 -03:00
commit 376a36b68d
11 changed files with 52 additions and 30 deletions

View file

@ -8,6 +8,7 @@ var ls = new LS();
// TODO move this to configService !
var config = copay.defaultConfig;
ls.getItem('config', function(err, data) {
var localConfig;
try {

View file

@ -160,6 +160,7 @@ angular.module('copayApp.controllers').controller('CreateProfileController', fun
$scope.error = 'Please enter the required fields';
return;
}
$scope.saveSettings(function(err) {
preconditions.checkState(!err, err);

View file

@ -133,8 +133,9 @@ angular.module('copayApp.controllers').controller('HomeController', function($sc
$scope.error = 'Invalid email or password. You are trying to sign in using ' + storage + '. Change it on settings is necessary.';
};
pinService.clear(function() {
});
$rootScope.hasPin = false;
pinService.clear(function() {});
} else if ((err.toString() || '').match('Connection')) {
$scope.error = 'Could not connect to Insight Server';
} else if ((err.toString() || '').match('Unable')) {

View file

@ -77,7 +77,6 @@ angular.module('copayApp.controllers').controller('SettingsController', function
configService.set({
network: insightSettings,
version: copay.version,
defaultLanguage: $scope.selectedLanguage.isoCode,
plugins: plugins,
logLevel: $scope.selectedLogLevel.name,

View file

@ -498,6 +498,7 @@ PublicKeyRing.prototype.getCosigner = function(pubKey) {
PublicKeyRing.prototype.buildAddressCache = function() {
var ret = [];
var self = this;
_.each(this.indexes, function(index) {
for (var i = 0; i < index.receiveIndex; i++) {
self._getAddress(i, false, index.copayerIndex);

View file

@ -350,6 +350,7 @@ Wallet.prototype._onPublicKeyRing = function(senderId, data) {
}
if (this.publicKeyRing.isComplete()) {
this._lockIncomming();
this.subscribeToAddresses();
this.emitAndKeepAlive('ready');
} else {
this.emitAndKeepAlive('publicKeyRingUpdated');
@ -739,7 +740,7 @@ Wallet.prototype._onData = function(senderId, data, ts) {
this._onSignature(senderId, data);
break;
case 'indexes':
this._onIndexes(data.indexes);
this._onIndexes(senderId, data);
break;
case 'addressbook':
this._onAddressBook(senderId, data);

View file

@ -1,20 +1,22 @@
'use strict';
angular.module('copayApp.services').factory('configService', function(localstorageService, gettextCatalog) {
angular.module('copayApp.services').factory('configService', function($timeout, localstorageService, gettextCatalog) {
var root = {};
root.set = function(opts, cb) {
// Options that have runtime effects
if (opts.logLevel)
copay.logger.setLevel(opts.logLevel);
if (opts.defaultLanguage)
gettextCatalog.currentLanguage = opts.defaultLanguage;
// Set current version
opts.version = copay.version;
localstorageService.getItem('config', function(err, oldOpsStr) {
var oldOpts = {};
try {
oldOpts = JSON.parse(oldOpsStr);
} catch (e) {};
@ -22,9 +24,8 @@ angular.module('copayApp.services').factory('configService', function(localstora
var newOpts = {};
_.extend(newOpts, copay.defaultConfig, oldOpts, opts);
// TODO remove this gloval variable.
// TODO remove this global variable.
config = newOpts;
localstorageService.setItem('config', JSON.stringify(newOpts), cb);
});
};

View file

@ -140,7 +140,7 @@ angular.module('copayApp.services')
};
root.notifyTxProposalEvent = function(w, e) {
if (e.cId == w.getMyCopayerId())
if (e.cId == w.getMyCopayerId())
return;
var user = w.publicKeyRing.nicknameForCopayer(e.cId);
@ -184,7 +184,8 @@ angular.module('copayApp.services')
w.on('ready', function() {
var isFocused = root.isFocused(wid);
copay.logger.debug('Wallet:' + w.getName() + ' is ready. Focused:', isFocused);
copay.logger.debug('Wallet:' + w.getName() +
' is ready. Focused:', isFocused);
balanceService.update(w, function() {
$rootScope.$digest();
@ -227,7 +228,7 @@ angular.module('copayApp.services')
// w.on('paymentACK', function(memo) {
// notification.success('Payment Acknowledged', memo);
// });
w.on('txProposalEvent', function(ev) {
if (root.isFocused(wid)) {
@ -241,7 +242,7 @@ angular.module('copayApp.services')
}, root.isFocused(wid));
root.notifyTxProposalEvent(w, ev);
$timeout(function(){
$timeout(function() {
$rootScope.$digest();
});
});
@ -269,7 +270,8 @@ angular.module('copayApp.services')
root.setupGlobalVariables(iden);
iden.on('newWallet', function(wid) {
var w = iden.getWalletById(wid);
copay.logger.debug('newWallet:', w.getName(), wid, iden.getLastFocusedWalletId());
copay.logger.debug('newWallet:',
w.getName(), wid, iden.getLastFocusedWalletId());
root.installWalletHandlers(w);
if (wid == iden.getLastFocusedWalletId()) {
copay.logger.debug('GOT Focused wallet:', w.getName());