From c1452901671f40f568e422853c5929946615338e Mon Sep 17 00:00:00 2001 From: Yemel Jardi Date: Tue, 8 Jul 2014 10:43:10 -0300 Subject: [PATCH] Add full backup stage with user feedback --- index.html | 25 +++++++++++++++---------- js/models/core/PublicKeyRing.js | 14 +++++++++++--- js/models/core/Wallet.js | 4 +++- 3 files changed, 29 insertions(+), 14 deletions(-) diff --git a/index.html b/index.html index ec93c6212..9d88b89c2 100644 --- a/index.html +++ b/index.html @@ -121,11 +121,9 @@ src="./img/satoshi.gif" /> - -

you

-
- -

{{c.nick}}

+ +

you{{c.nick}} + Backup ready

[SIN: {{c.peerId}}]
@@ -144,13 +142,13 @@ ng-show="!$root.wallet.publicKeyRing.isBackupReady()" ng-disabled="!$root.wallet.publicKeyRing.isComplete()"> - Backup keys + Backup the wallet - - {{$root.wallet.publicKeyRing.totalCopayers - $root.wallet.publicKeyRing.registeredCopayers() }} people have + + {{ $root.wallet.publicKeyRing.remainingCopayers() }} people have - + One person has yet to join. @@ -159,7 +157,14 @@ diff --git a/js/models/core/PublicKeyRing.js b/js/models/core/PublicKeyRing.js index 8bf663d6d..423c083eb 100644 --- a/js/models/core/PublicKeyRing.js +++ b/js/models/core/PublicKeyRing.js @@ -80,7 +80,11 @@ PublicKeyRing.prototype.registeredCopayers = function() { }; PublicKeyRing.prototype.isComplete = function() { - return this.registeredCopayers() === this.totalCopayers; + return this.remainingCopayers() == 0; +}; + +PublicKeyRing.prototype.remainingCopayers = function() { + return this.totalCopayers - this.registeredCopayers(); }; PublicKeyRing.prototype.getAllCopayerIds = function() { @@ -361,14 +365,18 @@ PublicKeyRing.prototype.setBackupReady = function(copayerId) { } PublicKeyRing.prototype.isBackupReady = function(copayerId) { - var cid = this.myCopayerId(); + var cid = copayerId || this.myCopayerId(); return this.copayersBackup.indexOf(cid) != -1; } PublicKeyRing.prototype.isFullyBackup = function(copayerId) { - return this.copayersBackup.length == this.totalCopayers; + return this.remainingBackups() == 0; } +PublicKeyRing.prototype.remainingBackups = function() { + return this.totalCopayers - this.copayersBackup.length; +}; + PublicKeyRing.prototype.merge = function(inPKR, ignoreId) { this._checkInPKR(inPKR, ignoreId); diff --git a/js/models/core/Wallet.js b/js/models/core/Wallet.js index fa7c8be57..8c530d90e 100644 --- a/js/models/core/Wallet.js +++ b/js/models/core/Wallet.js @@ -327,6 +327,7 @@ Wallet.prototype.getRegisteredPeerIds = function() { var pid = this.network.peerFromCopayer(cid); this.registeredPeerIds.push({ peerId: pid, + copayerId: cid, nick: this.publicKeyRing.nicknameForCopayer(cid), index: i, }); @@ -885,7 +886,8 @@ Wallet.prototype.isReady = function() { Wallet.prototype.setBackupReady = function() { this.publicKeyRing.setBackupReady(); - this.emit('publicKeyRingUpdated', false); + this.sendPublicKeyRing(); + this.store(); }; Wallet.prototype.signJson = function(payload) {