Add full backup stage with user feedback

This commit is contained in:
Yemel Jardi 2014-07-08 10:43:10 -03:00
commit c145290167
3 changed files with 29 additions and 14 deletions

View file

@ -121,11 +121,9 @@
src="./img/satoshi.gif"
/>
</span>
<span ng-show="c.index==0">
<p><b>you</b></p>
</span>
<span ng-show="c.index>0">
<p><b>{{c.nick}}</b></p>
<span>
<p><b ng-show="c.index==0">you</b><b ng-show="c.index>0">{{c.nick}}</b>
<span class="success label" ng-show="$root.wallet.publicKeyRing.isBackupReady(c.copayerId)">Backup ready</span></p>
<small>[SIN: {{c.peerId}}]</small>
</span>
</div>
@ -144,13 +142,13 @@
ng-show="!$root.wallet.publicKeyRing.isBackupReady()"
ng-disabled="!$root.wallet.publicKeyRing.isComplete()">
<span ng-show="$root.wallet.publicKeyRing.isComplete()" >
Backup keys
Backup the wallet
</span>
<span ng-show="!$root.wallet.publicKeyRing.isComplete()" >
<span ng-show="$root.wallet.publicKeyRing.totalCopayers - $root.wallet.publicKeyRing.registeredCopayers()>1">
{{$root.wallet.publicKeyRing.totalCopayers - $root.wallet.publicKeyRing.registeredCopayers() }} people have
<span ng-show="$root.wallet.publicKeyRing.remainingCopayers() > 1">
{{ $root.wallet.publicKeyRing.remainingCopayers() }} people have
</span>
<span ng-show="$root.wallet.publicKeyRing.totalCopayers - $root.wallet.publicKeyRing.registeredCopayers()==1">
<span ng-show="$root.wallet.publicKeyRing.remainingCopayers() == 1">
One person has
</span>
yet to join.
@ -159,7 +157,14 @@
<button class="button primary radius right"
disabled="disabled"
ng-show="$root.wallet.publicKeyRing.isBackupReady()">
Waiting for copayers to backup
<span ng-show="$root.wallet.publicKeyRing.remainingBackups() > 1">
{{ $root.wallet.publicKeyRing.remainingBackups() }} people have
</span>
<span ng-show="$root.wallet.publicKeyRing.remainingBackups() == 1">
One person has
</span>
yet to backup the wallet.
</span>
</button>
</div>
</div>

View file

@ -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);

View file

@ -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) {