fix order in receive

This commit is contained in:
Matias Alejo Garcia 2014-11-30 03:23:15 -03:00
commit abaf5b8f13
5 changed files with 109 additions and 69 deletions

View file

@ -1,7 +1,7 @@
'use strict';
angular.module('copayApp.controllers').controller('ImportProfileController',
function($scope, $rootScope, $location, notification, isMobile, pluginManager, identityService) {
function($scope, $rootScope, $location, notification, isMobile, identityService) {
$scope.title = 'Import a backup';
$scope.importStatus = 'Importing wallet - Reading backup...';
$scope.hideAdv = true;
@ -18,6 +18,8 @@ angular.module('copayApp.controllers').controller('ImportProfileController',
var password = $scope.password;
updateStatus('Importing profile - Setting things up...');
identityService.importProfile(str,password, function(err){
})
copay.Identity.importFromEncryptedFullJson(str, password, {
pluginManager: pluginManager,
network: config.network,
@ -55,10 +57,8 @@ angular.module('copayApp.controllers').controller('ImportProfileController',
};
$scope.import = function(form) {
$scope.loading = true;
if (form.$invalid) {
$scope.loading = false;
$scope.error = 'Please enter the required fields';
return;
}
@ -67,11 +67,11 @@ angular.module('copayApp.controllers').controller('ImportProfileController',
var password = form.password.$modelValue;
if (!backupFile && !backupText) {
$scope.loading = false;
$scope.error = 'Please, select your backup file';
return;
}
$scope.loading = true;
if (backupFile) {
reader.readAsBinaryString(backupFile);
} else {

View file

@ -5,16 +5,14 @@ angular.module('copayApp.controllers').controller('ReceiveController',
$rootScope.title = 'Receive';
$scope.loading = false;
$scope.showAll = false;
$scope.isNewAddr = false;
$scope.newAddr = function() {
var w = $rootScope.wallet;
$scope.loading = true;
$scope.isNewAddr = false;
w.generateAddress(null);
$scope.setAddressList();
$timeout(function() {
$scope.loading = false;
$scope.isNewAddr = true;
}, 1);
};
@ -39,55 +37,32 @@ angular.module('copayApp.controllers').controller('ReceiveController',
});
};
$rootScope.$watch('addrInfos', function() {
if ($rootScope.updatingBalance) return;
$scope.addressList();
});
$scope.toggleShowAll = function() {
$scope.showAll = !$scope.showAll;
$scope.addressList();
$scope.setAddressList();
};
$scope.limitAddress = function(elements, isNewAddr) {
if(!isNewAddr){
elements = elements.sort(function(a, b) {
return (+a.isChange - +b.isChange);
});
}
if (elements.length <= 1 || $scope.showAll) {
return elements;
}
// Show last 3 non-change addresses plus those with balance
var addrs = elements.filter(function(e, i) {
return (!e.isChange && i < 3) || (e.balance && e.balance > 0);
});
return addrs;
};
$scope.addressList = function() {
$scope.addresses = [];
$scope.setAddressList = function() {
var w = $rootScope.wallet;
var balance = $rootScope.balanceByAddr;
var addresses = w.getAddresses();
var addresses = w.getAddressesOrderer();
if (addresses) {
$scope.addrLength = addresses.length;
if (!$scope.showAll)
addresses = addresses.slice(0,3);
var list = [];
_.each(addresses, function(address, index){
$scope.addresses.push({
list.push({
'index': index,
'address': address,
'balance': balance ? balance[address] : 0,
'isChange': w.addressIsChange(address),
// TODO
'owned': w.addressIsOwn(address),
});
});
$scope.addresses = $scope.limitAddress($scope.addresses, $scope.isNewAddr);
$scope.addresses = list;
}
};
}