diff --git a/js/models/Identity.js b/js/models/Identity.js index 33f267337..85c568508 100644 --- a/js/models/Identity.js +++ b/js/models/Identity.js @@ -237,6 +237,8 @@ Identity.prototype.retrieveWalletFromStorage = function(walletId, opts, cb) { * @param {Function} cb */ Identity.prototype.storeWallet = function(wallet, cb) { + var self = this; + preconditions.checkArgument(wallet && _.isObject(wallet)); wallet.setVersion(this.version); @@ -246,8 +248,14 @@ Identity.prototype.storeWallet = function(wallet, cb) { this.storage.setItem(key, val, function(err) { if (err) { - log.error('Wallet:' + wallet.getName() + ' couldnt be stored:', err); + log.error('Wallet:' + wallet.getName() + ' could not be stored:', err); log.error('Wallet:' + wallet.getName() + ' Size:', JSON.stringify(wallet.sizes())); + + if (err.match('OVERQUOTA')) { + self.emitAndKeepAlive('walletStorageError', wallet.getId(), 'Storage limits on remote server exceeded'); + } else { + self.emitAndKeepAlive('walletStorageError', wallet.getId(), err); + } } if (cb) return cb(err); @@ -576,12 +584,9 @@ Identity.prototype.createWallet = function(opts, cb) { var self = this; var w = new walletClass(opts); - console.log(_.keys(self.wallets)); - console.log(w.getId()); - if (_.contains(_.keys(self.wallets), w.getId())) { + if (self.wallets[w.getId()]) { return cb('walletAlreadyExists'); } - self.wallets[w.getId()] = w; self.updateFocusedTimestamp(w.getId()); self.bindWallet(w); diff --git a/js/services/identityService.js b/js/services/identityService.js index 584ab4615..9c2361ef5 100644 --- a/js/services/identityService.js +++ b/js/services/identityService.js @@ -307,6 +307,10 @@ angular.module('copayApp.services') // do nothing. this is handled 'on sync' on controller. }); + iden.on('walletStorageError', function (wid, message) { + notification.error('Error storing wallet', message); + }); + iden.on('closed', function() { delete $rootScope['wallet']; delete $rootScope['iden'];