add redirs to internal pages
This commit is contained in:
parent
572dff6baf
commit
bdaf40de48
11 changed files with 88 additions and 65 deletions
|
|
@ -2,6 +2,9 @@
|
||||||
|
|
||||||
angular.module('copayApp.controllers').controller('AddressesController',
|
angular.module('copayApp.controllers').controller('AddressesController',
|
||||||
function($scope, $rootScope, $timeout, $modal, controllerUtils) {
|
function($scope, $rootScope, $timeout, $modal, controllerUtils) {
|
||||||
|
controllerUtils.redirIfNotComplete();
|
||||||
|
|
||||||
|
|
||||||
$scope.loading = false;
|
$scope.loading = false;
|
||||||
$scope.showAll = false;
|
$scope.showAll = false;
|
||||||
var w = $rootScope.wallet;
|
var w = $rootScope.wallet;
|
||||||
|
|
|
||||||
|
|
@ -139,9 +139,8 @@ angular.module('copayApp.controllers').controller('JoinController',
|
||||||
notification.error('Unknown error');
|
notification.error('Unknown error');
|
||||||
controllerUtils.onErrorDigest();
|
controllerUtils.onErrorDigest();
|
||||||
} else {
|
} else {
|
||||||
$scope.loading = false;
|
controllerUtils.installWalletHandlers($scope, w);
|
||||||
$rootScope.wallet = w;
|
controllerUtils.setFocusedWallet(w);
|
||||||
controllerUtils.bindWallet(w, $scope);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,9 +2,11 @@
|
||||||
|
|
||||||
angular.module('copayApp.controllers').controller('MoreController',
|
angular.module('copayApp.controllers').controller('MoreController',
|
||||||
function($scope, $rootScope, $location, $filter, backupService, controllerUtils, notification, rateService) {
|
function($scope, $rootScope, $location, $filter, backupService, controllerUtils, notification, rateService) {
|
||||||
|
controllerUtils.redirIfNotComplete();
|
||||||
var w = $rootScope.wallet;
|
var w = $rootScope.wallet;
|
||||||
$scope.isSafari = Object.prototype.toString.call(window.HTMLElement).indexOf('Constructor') > 0;
|
$scope.isSafari = Object.prototype.toString.call(window.HTMLElement).indexOf('Constructor') > 0;
|
||||||
|
|
||||||
|
|
||||||
$scope.unitOpts = [{
|
$scope.unitOpts = [{
|
||||||
name: 'Satoshis (100,000,000 satoshis = 1BTC)',
|
name: 'Satoshis (100,000,000 satoshis = 1BTC)',
|
||||||
shortName: 'SAT',
|
shortName: 'SAT',
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,8 @@ var preconditions = require('preconditions').singleton();
|
||||||
|
|
||||||
angular.module('copayApp.controllers').controller('SendController',
|
angular.module('copayApp.controllers').controller('SendController',
|
||||||
function($scope, $rootScope, $window, $timeout, $anchorScroll, $modal, isMobile, notification, controllerUtils, rateService) {
|
function($scope, $rootScope, $window, $timeout, $anchorScroll, $modal, isMobile, notification, controllerUtils, rateService) {
|
||||||
|
controllerUtils.redirIfNotComplete();
|
||||||
|
|
||||||
var w = $rootScope.wallet;
|
var w = $rootScope.wallet;
|
||||||
preconditions.checkState(w);
|
preconditions.checkState(w);
|
||||||
preconditions.checkState(w.settings.unitToSatoshi);
|
preconditions.checkState(w.settings.unitToSatoshi);
|
||||||
|
|
|
||||||
|
|
@ -36,12 +36,14 @@ angular.module('copayApp.controllers').controller('SidebarController', function(
|
||||||
|
|
||||||
$scope.refresh = function() {
|
$scope.refresh = function() {
|
||||||
var w = $rootScope.wallet;
|
var w = $rootScope.wallet;
|
||||||
|
if (w.isReady()) {
|
||||||
w.sendWalletReady();
|
w.sendWalletReady();
|
||||||
if ($rootScope.addrInfos.length > 0) {
|
if ($rootScope.addrInfos.length > 0) {
|
||||||
controllerUtils.updateBalance(function() {
|
controllerUtils.updateBalance(function() {
|
||||||
$rootScope.$digest();
|
$rootScope.$digest();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
$scope.isActive = function(item) {
|
$scope.isActive = function(item) {
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,8 @@ var bitcore = require('bitcore');
|
||||||
|
|
||||||
angular.module('copayApp.controllers').controller('TransactionsController',
|
angular.module('copayApp.controllers').controller('TransactionsController',
|
||||||
function($scope, $rootScope, $timeout, controllerUtils, notification, rateService) {
|
function($scope, $rootScope, $timeout, controllerUtils, notification, rateService) {
|
||||||
|
controllerUtils.redirIfNotComplete();
|
||||||
|
|
||||||
|
|
||||||
var w = $rootScope.wallet;
|
var w = $rootScope.wallet;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -297,6 +297,14 @@ Wallet.prototype.seedCopayer = function(pubKey) {
|
||||||
this.seededCopayerId = pubKey;
|
this.seededCopayerId = pubKey;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
Wallet.prototype._newAddresses = function(dontUpdateUx) {
|
||||||
|
if (this.publicKeyRing.isComplete()) {
|
||||||
|
this.subscribeToAddresses();
|
||||||
|
};
|
||||||
|
this.emit('newAddresses', dontUpdateUx);
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @desc Handles an 'indexes' message.
|
* @desc Handles an 'indexes' message.
|
||||||
*
|
*
|
||||||
|
|
@ -307,14 +315,13 @@ Wallet.prototype.seedCopayer = function(pubKey) {
|
||||||
*
|
*
|
||||||
* @param {string} senderId - the sender id
|
* @param {string} senderId - the sender id
|
||||||
* @param {Object} data - the data recived, {@see HDParams#fromList}
|
* @param {Object} data - the data recived, {@see HDParams#fromList}
|
||||||
* @emits publicKeyRingUpdated
|
|
||||||
*/
|
*/
|
||||||
Wallet.prototype._onIndexes = function(senderId, data) {
|
Wallet.prototype._onIndexes = function(senderId, data) {
|
||||||
log.debug('Wallet:' + this.id + ' RECV INDEXES:', data);
|
log.debug('Wallet:' + this.id + ' RECV INDEXES:', data);
|
||||||
var inIndexes = HDParams.fromList(data.indexes);
|
var inIndexes = HDParams.fromList(data.indexes);
|
||||||
var hasChanged = this.publicKeyRing.mergeIndexes(inIndexes);
|
var hasChanged = this.publicKeyRing.mergeIndexes(inIndexes);
|
||||||
if (hasChanged) {
|
if (hasChanged) {
|
||||||
this.emit('publicKeyRingUpdated');
|
this._newAddresses();
|
||||||
this.store();
|
this.store();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
@ -352,7 +359,6 @@ Wallet.prototype.changeSettings = function(settings) {
|
||||||
* @param {Object} data - the data recived, {@see HDParams#fromList}
|
* @param {Object} data - the data recived, {@see HDParams#fromList}
|
||||||
* @param {Object} data.publicKeyRing - data to be deserialized into a {@link PublicKeyRing}
|
* @param {Object} data.publicKeyRing - data to be deserialized into a {@link PublicKeyRing}
|
||||||
* using {@link PublicKeyRing#fromObj}
|
* using {@link PublicKeyRing#fromObj}
|
||||||
* @emits publicKeyRingUpdated
|
|
||||||
* @emits connectionError
|
* @emits connectionError
|
||||||
*/
|
*/
|
||||||
Wallet.prototype._onPublicKeyRing = function(senderId, data) {
|
Wallet.prototype._onPublicKeyRing = function(senderId, data) {
|
||||||
|
|
@ -377,7 +383,7 @@ Wallet.prototype._onPublicKeyRing = function(senderId, data) {
|
||||||
if (this.publicKeyRing.isComplete()) {
|
if (this.publicKeyRing.isComplete()) {
|
||||||
this._lockIncomming();
|
this._lockIncomming();
|
||||||
}
|
}
|
||||||
this.emit('publicKeyRingUpdated');
|
this._newAddresses();
|
||||||
this.store();
|
this.store();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
@ -664,16 +670,13 @@ Wallet.prototype._onData = function(senderId, data, ts) {
|
||||||
preconditions.checkArgument(_.isNumber(ts));
|
preconditions.checkArgument(_.isNumber(ts));
|
||||||
log.debug('Wallet:' + this.id + ' RECV', senderId, data);
|
log.debug('Wallet:' + this.id + ' RECV', senderId, data);
|
||||||
|
|
||||||
console.log('[Wallet.js.635]'); //TODO
|
|
||||||
this.updateTimestamp(ts);
|
this.updateTimestamp(ts);
|
||||||
|
|
||||||
console.log('[Wallet.js.638]'); //TODO
|
|
||||||
if (data.type !== 'walletId' && this.id !== data.walletId) {
|
if (data.type !== 'walletId' && this.id !== data.walletId) {
|
||||||
log.debug('Wallet:' + this.id + ' Received corrupt message:', data)
|
log.debug('Wallet:' + this.id + ' Received corrupt message:', data)
|
||||||
this.emit('corrupt', senderId);
|
this.emit('corrupt', senderId);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
console.log('[Wallet.js.644]'); //TODO
|
|
||||||
|
|
||||||
switch (data.type) {
|
switch (data.type) {
|
||||||
// This handler is repeaded on WalletFactory (#join). TODO
|
// This handler is repeaded on WalletFactory (#join). TODO
|
||||||
|
|
@ -903,7 +906,6 @@ Wallet.prototype._setBlockchainListeners = function() {
|
||||||
* @emits data
|
* @emits data
|
||||||
*
|
*
|
||||||
* @emits ready
|
* @emits ready
|
||||||
* @emits publicKeyRingUpdated
|
|
||||||
* @emits txProposalsUpdated
|
* @emits txProposalsUpdated
|
||||||
*
|
*
|
||||||
* @TODO: FIX PROTOCOL -- emit with a space is shitty
|
* @TODO: FIX PROTOCOL -- emit with a space is shitty
|
||||||
|
|
@ -947,13 +949,12 @@ Wallet.prototype.netStart = function() {
|
||||||
net.start(startOpts, function() {
|
net.start(startOpts, function() {
|
||||||
log.debug('Wallet:' + self.id + ' Networking ready:', net.copayerId);
|
log.debug('Wallet:' + self.id + ' Networking ready:', net.copayerId);
|
||||||
self._setBlockchainListeners();
|
self._setBlockchainListeners();
|
||||||
self.subscribeToAddresses();
|
|
||||||
self.emit('ready', net.getPeer());
|
self.emit('ready', net.getPeer());
|
||||||
setTimeout(function() {
|
setTimeout(function() {
|
||||||
self.emit('publicKeyRingUpdated', true);
|
self._newAddresses(true);
|
||||||
// no connection logic for now
|
// no connection logic for now
|
||||||
self.emit('txProposalsUpdated');
|
self.emit('txProposalsUpdated');
|
||||||
}, 10);
|
}, 0);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -2479,7 +2480,6 @@ Wallet.prototype.createTxSync = function(toAddress, amountSatStr, comment, utxos
|
||||||
*
|
*
|
||||||
* Triggers a wallet {@link Wallet#store} call
|
* Triggers a wallet {@link Wallet#store} call
|
||||||
* @param {Function} callback - called when all indexes have been updated. Receives an error, if any, as first argument
|
* @param {Function} callback - called when all indexes have been updated. Receives an error, if any, as first argument
|
||||||
* @emits publicKeyRingUpdated
|
|
||||||
*/
|
*/
|
||||||
Wallet.prototype.updateIndexes = function(callback) {
|
Wallet.prototype.updateIndexes = function(callback) {
|
||||||
var self = this;
|
var self = this;
|
||||||
|
|
@ -2494,7 +2494,7 @@ Wallet.prototype.updateIndexes = function(callback) {
|
||||||
async.parallel(tasks, function(err) {
|
async.parallel(tasks, function(err) {
|
||||||
if (err) callback(err);
|
if (err) callback(err);
|
||||||
log.debug('Wallet:' + self.id + ' Indexes updated');
|
log.debug('Wallet:' + self.id + ' Indexes updated');
|
||||||
self.emit('publicKeyRingUpdated');
|
self._newAddresses();
|
||||||
self.store();
|
self.store();
|
||||||
callback();
|
callback();
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,19 @@ angular.module('copayApp.services')
|
||||||
.factory('controllerUtils', function($rootScope, $sce, $location, $filter, notification, $timeout, uriHandler, rateService) {
|
.factory('controllerUtils', function($rootScope, $sce, $location, $filter, notification, $timeout, uriHandler, rateService) {
|
||||||
var root = {};
|
var root = {};
|
||||||
|
|
||||||
|
|
||||||
|
root.redirIfNotComplete = function() {
|
||||||
|
var w = $rootScope.wallet;
|
||||||
|
if (w) {
|
||||||
|
if (!w.isReady()) {
|
||||||
|
$location.path('/copayers');
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$location.path('/');
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
root.redirIfLogged = function() {
|
root.redirIfLogged = function() {
|
||||||
var w = $rootScope.wallet;
|
var w = $rootScope.wallet;
|
||||||
if (w) {
|
if (w) {
|
||||||
|
|
@ -80,7 +93,7 @@ angular.module('copayApp.services')
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
w.on('publicKeyRingUpdated', function(dontDigest) {
|
w.on('newAddresses', function(dontDigest) {
|
||||||
if (root.isFocusedWallet(wid)) {
|
if (root.isFocusedWallet(wid)) {
|
||||||
root.updateAddressList();
|
root.updateAddressList();
|
||||||
if (!dontDigest) {
|
if (!dontDigest) {
|
||||||
|
|
@ -205,7 +218,6 @@ angular.module('copayApp.services')
|
||||||
|
|
||||||
$rootScope.wallet = w;
|
$rootScope.wallet = w;
|
||||||
root.updateAddressList();
|
root.updateAddressList();
|
||||||
|
|
||||||
root.redirIfLogged();
|
root.redirIfLogged();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -126,7 +126,7 @@ describe('Profile model', function() {
|
||||||
p.addWallet('123', {}, function(err) {
|
p.addWallet('123', {}, function(err) {
|
||||||
p.addWallet('234', {}, function(err) {
|
p.addWallet('234', {}, function(err) {
|
||||||
p.addWallet('345', {}, function(err) {
|
p.addWallet('345', {}, function(err) {
|
||||||
_.pluck(p.listWallets(), 'id').should.deep.equal(['123', '234', '345']);
|
_.pluck(p.listWallets(), 'id').sort().should.deep.equal(['123', '234', '345']);
|
||||||
p.deleteWallet('234', function(err) {
|
p.deleteWallet('234', function(err) {
|
||||||
_.pluck(p.listWallets(), 'id').should.deep.equal(['123', '345']);
|
_.pluck(p.listWallets(), 'id').should.deep.equal(['123', '345']);
|
||||||
done();
|
done();
|
||||||
|
|
@ -14,6 +14,8 @@ FakeBlockchain.prototype.getTransactions = function(addresses, cb) {
|
||||||
cb(null, []);
|
cb(null, []);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
FakeBlockchain.prototype.subscribe = function() {
|
||||||
|
};
|
||||||
|
|
||||||
FakeBlockchain.prototype.fixUnspent = function(u) {
|
FakeBlockchain.prototype.fixUnspent = function(u) {
|
||||||
this.u = u;
|
this.u = u;
|
||||||
|
|
|
||||||
|
|
@ -35,7 +35,6 @@
|
||||||
<div ng-if="!$root.wallet.publicKeyRing.isComplete()">
|
<div ng-if="!$root.wallet.publicKeyRing.isComplete()">
|
||||||
<img
|
<img
|
||||||
class="waiting br100"
|
class="waiting br100"
|
||||||
ng-if="!hasVideo(copayer)"
|
|
||||||
src="./img/satoshi.gif"
|
src="./img/satoshi.gif"
|
||||||
alt="Waiting Copayer"
|
alt="Waiting Copayer"
|
||||||
width="70">
|
width="70">
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue